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

How to use SUBSTR in Visual Basic 6

Status
Not open for further replies.

cmaknp

Programmer
Aug 28, 2002
25
IN
Hello I m VB6 Programmer, but new..or biginner..:)

I want to know..how to use in VB6

like in Foxpro2.6
text = "Culture"
subs(text, 3, 4)

so if in VB6
text1.text = "Culture"

so how to use substr command in VB6

pls guide
 
Hi,

The function is called 'Mid' in VB. If you are sure you input is a string you can use 'Mid$' which is faster.

------------------------------------------------
Dim MyString as string
Text1.text = "Culture"
MyString = Mid$(Text1.Text,3,4)
------------------------------------------------

Sunaj
'The gap between theory and practice is not as wide in theory as it is in practice'
 
Try Mid(Text1.text,3,4)

Look up in VBHelp for details, but first parameter is the string, second is start position and third is number of characters Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
A undocumented note/feature of the MID() function.

Not only can the MID() function be used on the right side of an assignment like
Code:
DIM sSource as String
Dim sPart as String

sSource = "Hello World"
sPart = MID(sSource,4,5)

but MID can be used on the left side of an assignment like so

Code:
DIM sSource as String

sSource = "Hello World"
MID(sSource,4,5) = "ABCDE"

the result of the above code leaves sSource with
HelABCDErld

Don't ask me....the programmer assigned to do the MID function just got ambitious.....and no it doesn't work with RIGHT() and LEFT().
 
SemperFi,
FYI
It's actually documented under Mid statement in MSDN/VbHelp as doing this Let me know if this helps
________________________________________________________________
If you are worried about how to post, please check out FAQ222-2244 first

'There are 10 kinds of people in the world: those who understand binary, and those who don't.'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top