Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check what a character is

Status
Not open for further replies.

bf2mad

Programmer
Nov 26, 2002
33
GB
Hi,

I am using MS Access 2000 and I am stuck with a bit of VB

How can I check if character number n = "\" in a string.

I have a For Next loop and I want to run though the string until \ is found.

I already have the length on the string is a variable fullNum

So my for loop starts as so

For n = 1 to fullnum

And then I have done brain dead.

Any help would be excellent

Many Thanks Phil
 
You can use the built-in basic function InStr() as follows:
Code:
Option Explicit
Sub test()
Dim MyString As String
  MyString = "xxxxx/xxx"
  If InStr(MyString, "/") > 0 Then
    MsgBox "found"
  Else
    MsgBox "not found"
  End If
End Sub


 
Private Sub Command1_Click()
Dim strInitialString As String
Dim lReturnPosition As Long

strInitialString = Text1.Text

lReturnPosition = InStr(1, strInitialString, "/", vbTextCompare)
If lReturnPosition <> 0 Then
MsgBox &quot; / Found&quot;
Else
MsgBox &quot;NotFound &quot;
End If
Print lReturnPosition & &quot;,&quot; & Len(strInitialString)
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top