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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quick question

Status
Not open for further replies.

jadepatel

Technical User
Sep 4, 2002
35
0
0
GB
Hi, Im new to VB6 programming and wanted to know how i would use a similar function like the sql server substring in vb6.

what i want to do is scan a text file in coloumns 19-20 and if it contains the value '10', carry out a specific command. If it doesnt i want to run anothet piece of code.

Can anyone help?
This is what i usually do in sql server...
if substring(ots,19,2) = '10' then
 
if instr([start position], [string to search in],[string to look for]) then
...

end if

that should help you, you just need to set the start location, and probably and end location too if you just want to search one row. perhaps take the data in that row to another string and search it.

hope this helps!
 
Hi,
Where would i specify the end location?
 
newstring = mid([string],[start],[length])
position = instr([start],newstring, "10")

newstring will just be the section you want and position will be the numeric position of the first ocurance of "10" in newstring, -1 if its not found.
 
Code:
If Mid(strString, 19, 2)="10" Then
   'Perform your code
Else
   'Perform your alternate action
End If
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top