?????? ????????????? ??? Microsoft Visual Basic 6.0 ?? ????? ???? ????

???? ?????? ???? ??????
???? ID: 818802 - ?? ???????? ?? ?????? ??? ?? ?? ???? ???? ???? ??.
??? ?? ??????? ???? | ??? ?? ??????? ????

?? ????? ??

??????

?? ??? ?? ??? ???? ????? ???? ?? ?? ?????? ????????????? ????? ?? ??? ???? ???? ?? ????????? ???? ?? ???? ?????????? ??????? ???????? ????? ???? ?? ??? ?????? ????????????? ?? ????? ???? ????? ?????? ????????????? ?????? ???????? ?? ?????????? ?? ?? ??????? ???????? ?? ??? ???? ?? ?????? ???? ??? ?? Microsoft VBScript ?????? ????????????? 5.5 ????????? ??? ?????? ??? ?? ???????? ?? ????? ?? ?? ???? ??? ???? ??????? ???????? ?? ??????? ??? ???????? ?? ????? ????, ?? ???????? ???????? ?? ???? ???????? ?? ??? ?? ???? ?? ???????? ???????? ?? ????? ?? ???? ???????? ?? ???? ????? ???? ?? ?? ???? ?? ???????? ?? ?????? ?? ?? ???? ???????? ?? ?? ???? ???????? ?? ????? ???? ?? ??? ?? ???????? ??????



??????????


????? ???? outlines ???????? ?????????, ??????????, ??????? ??????, ?? ???? ?????? ???? ???:
  • Microsoft Visual Basic 6.0
?? ???? ????? ?? ?? ?? ????? ???? ?? ?????? ???:
  • Visual Basic 6.0
  • ?????? ?????????? ????????


?????? ????????????? ?? ????? ?? ???? ???????? ????? ?? ???



6.0 ?? ???, Visual Basic ???RegExp???????? ???? ???????? ????? ?? ??? ?????? ????????????? ?? ????? ???? ??? ????? ??? ?????? ?????? ??? ?? ???RegExp. ?? ??? ??? ???? ??? ??? ??? ??? ?? ?????????? ?? ????? ???? ?? ??? ????????RegExp??????:
  • ????????: ?? ???????? ?? ?? ?????? ?????????? ????????? ???? ???
  • IgnoreCase: ??? ?????? ??? ?? ????? ???? ?? ?? ?? ?????? ??????? ???? ?? ??? ??????? ?? ??????? ?????? ?????????? ??? ?? ???????? ???
  • ???????: ??? ?????? ??? ??? ???? ?? ?? ?? ????? ???? ?? ?? ???? ???????? ???? ??? ???????? ??? ??? ???????? ????? ?????, ?? ???? ???????? ?? ???? ????? ??????? ?? ????? ????? ?????? ??? ???? ???
RegExp????????? ???? ?? ???? ??? ???????? ?? ?????? ?????????? ?? ?? ????? ???????? ?? ??? ???? ?? ??? ????? ??????? ?????? ????? ??:
  • Test: ??? ?? ?? ?????? ?????????? ???? ??????????? ???? ?? ??? ???????? ?? ??????? ?? ????? ???? ??? ?????? ??? ???? ???
  • ????????? ????: ???? ?? ??MatchCollection???????? ??? ????????????? ??? ????? ?? ??? ???????? ???
To match a string to a regular expression, follow these steps:
  1. Set the regular expression by using the?????????? ??? ????RegExp???????? ???
  2. Obtain the string to examine with the pattern.
  3. ??? ????IgnoreCase?? ???RegExpobject toTrue.
  4. Pass the string that you obtained in step 2 as an argument to the????????? ?????? ??? ????RegExp???????? ???
  5. Assign the return value of the????????? ???????? ?? ??? ????MatchCollection???????? ???

    TheMatchCollectionobject contains information about the matched strings.

???:?? ????? ?? ????Testmethod to determine whether the string matches the specific regular expression.

Step-by-Step ??????

  1. Microsoft Visual Basic 6.0 ?? ??????? ?????
  2. ????? ???????????? ??,??? ?????????.
  3. ????? ????,Standard Exe???????? ?????????????? ????? ??? ??? ????? ?? ???? ????, ?? ???? ???OK.

    ???????? ??? ??, Form1 ??? ???? ???? ??..
  4. ????? ????????????????? ??,??????.
  5. ???-????? ????Microsoft VBScript Regular Expressions 5.5?? ????-????? ????, ?? ???? ???OK.
  6. ????? ??? ??? ????? ????CommandButton.

    By defaultCommand1is added to the form.
  7. ???-????? ????Command1to open the Code window.
  8. ??? ????? ??? ???????Command1_Click????? ??????:
    MsgBox(TestRegExp("is.", "IS1 is2 IS3 is4"))
    ???:?? ?????? ???,???"IS1 is2 IS3 is4" ???????? ?? ??????? ???????? ?? ??? ???? ??? ??? ????? ???? period (?? ????? ?? ???? ???.) ???? ?? ???????? ???? ??? ?? ??? ?? ?? ??? ???????? ?? ??? ????????? ???? ??????????? ???? ?? ??? ??? ????? ???? ?? ???? ??? ???????? ???? ?? ??? ?? ??????? ??????, ??? ???? ?? ???????? ???? ????? ??? ??? ?? ???? ?? ??????? ?? ????? ????, ?? ?? ???? ????? ??? ?????????
  9. ????? ????? ???? ?? ??? ?????Command1_click????? ??????:
    Function TestRegExp(myPattern As String, myString As String)
       'Create objects.
       Dim objRegExp As RegExp
       Dim objMatch As Match
       Dim colMatches   As MatchCollection
       Dim RetStr As String
       
       ' Create a regular expression object.
       Set objRegExp = New RegExp
    
       'Set the pattern by using the Pattern property.
       objRegExp.Pattern = myPattern
    
       ' Set Case Insensitivity.
       objRegExp.IgnoreCase = True
    
       'Set global applicability.
       objRegExp.Global = True
    
       'Test whether the String can be compared.
       If (objRegExp.Test(myString) = True) Then
    
       'Get the matches.
        Set colMatches = objRegExp.Execute(myString)   ' Execute search.
    
        For Each objMatch In colMatches   ' Iterate Matches collection.
          RetStr = RetStr & "Match found at position "
          RetStr = RetStr & objMatch.FirstIndex & ". Match Value is '"
          RetStr = RetStr & objMatch.Value & "'." & vbCrLf
        Next
       Else
        RetStr = "String Matching Failed"
       End If
       TestRegExp = RetStr
    End Function
  10. ????? ????????????? ??,???????????????? ??????
  11. ????? ????,Command1.

    ??? ????? ????? ?? ??? ?????????????? ?? ???? ?? ?? ????????? ???? ?????????IS1 is2 IS3 is4?????????

??????

???? ??????? ?? ???, ????? MSDN ??? ???? ?? ????:
HTTP://msdn2.Microsoft.com/en-us/library/6wzad2b2.aspx

???

???? ID: 818802 - ????? ???????: 05 ?????? 2010 - ??????: 2.0
???? ???? ???? ??:
  • Microsoft Visual Basic 6.0 Professional Edition
??????: 
kbprogramming kbstring kbhowtomaster kbmt KB818802 KbMthi
???? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:818802

??????????? ???

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com