Originally Written By TheVBProgramer. Cleaned up and reformatted for this site.
NOTE: This tutorial uses The VB Test Harness. If you have not already created this test harness please do so first. It will make this tutorial a lot easier to follow.
VB has numerous built-in string functions for processing strings. Most VB string-handling functions return a string, although some return a number (such as the Len function, which returns the length of a string and functions like Instr and InstrRev, which return a character position within the string). The functions that return strings can be coded with or without the dollar sign ($) at the end, although it is more efficient to use the version with the dollar sign.
The first time I started trying to understand the VB6 string functions I was somewhat confused. This tutorial will walk you through all the different ways you can us VB to handle strings. If you are still confused feel free to post a comment and hopefully we can help get you cleared up. Also there are many other string related tutorials on this site so feel free to browse around.
Function: |
Len |
Description: |
Returns a Long containing the length of the specified string |
Syntax: |
Len(string) Where string is the string whose length (number of characters) is to be returned. |
Example: |
|
Function: |
Mid$ (or Mid) |
Description: |
Returns a substring containing a specified number of characters from a string. |
Syntax: |
Mid$(string, start[, length]) The Mid$ function syntax has these parts: string Required. String expression from which characters are returned. start Required; Long. Character position in string at which the part to be taken begins. If start is greater than the number of characters in string, Mid returns a zero-length string (""). length Optional; Long. Number of characters to return. If omitted or if there are fewer than length characters in the text (including the character at start), all characters from the start position to the end of the string are returned. |
Example: |
Note: Mid$ can also be used on the left side of an assignment statement, where you can replace a substring within a string.
In VB6, the Replace$ function was introduced, which can also be used to replace characters within a string. |
Function: |
Left$ (or Left) |
Description: |
Returns a substring containing a specified number of characters from the beginning (left side) of a string. |
Syntax: |
Left$(string, length) The Left$ function syntax has these parts: string Required. String expression from which the leftmost characters are returned. length Required; Long. Numeric expression indicating how many characters to return. If 0, a zero-length string ("") is returned. If greater than or equal to the number of characters in string, the entire string is returned.
|
Example: |
|
Function: |
Right$ (or Right) |
Description: |
Returns a substring containing a specified number of characters from the end (right side) of a string. |
Syntax: |
Right$(string, length) The Right$ function syntax has these parts: string Required. String expression from which the rightmost characters are returned. length Required; Long. Numeric expression indicating how many characters to return. If 0, a zero-length string ("") is returned. If greater than or equal to the number of characters in string, the entire string is returned. |
Example: |
|
Function: |
UCase$ (or UCase) |
Description: |
Converts all lowercase letters in a string to uppercase. Any existing uppercase letters and non-alpha characters remain unchanged. |
Syntax: |
UCase$(string) |
Example: |
|
Function: |
LCase$ (or LCase) |
Description: |
Converts all uppercase letters in a string to lowercase. Any existing lowercase letters and non-alpha characters remain unchanged. |
Syntax: |
LCase$(string) |
Example: |
|
Function: |
Instr |
Description: |
Returns a Long specifying the position of one string within another. The search starts either at the first character position or at the position specified by the start argument, and proceeds forward toward the end of the string (stopping when either string2 is found or when the end of the string1 is reached). |
Syntax: |
InStr([start,] string1, string2 [, compare]) The InStr function syntax has these parts: start Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. The start argument is required if compare is specified. string1 Required. String expression being searched. string2 Required. String expression sought. compare Optional; numeric. A value of 0 (the default) specifies a binary (case-sensitive) search. A value of 1 specifies a textual (case-insensitive) search. |
Examples: |
|
Function: |
InstrRev |
Description: |
Returns a Long specifying the position of one string within another. The search starts either at the last character position or at the position specified by the start argument, and proceeds backward toward the beginning of the string (stopping when either string2 is found or when the beginning of the string1 is reached). Introduced in VB 6. |
Syntax: |
InStrRev(string1, string2[, start, [, compare]]) The InStr function syntax has these parts: string1 Required. String expression being searched. string2 Required. String expression sought. start Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the last character position. compare Optional; numeric. A value of 0 (the default) specifies a binary (case-sensitive) search. A value of 1 specifies a textual (case-insensitive) search. |
Examples: |
|
Notes on Instr and InstrRev:
· Something to watch out for is that while Instr and InstrRev both accomplish the same thing (except that InstrRev processes a string from last character to first, while Instr processes a string from first character to last), the arguments to these functions are specified in a different order. The Instr arguments are (start, string1, string2, compare) whereas the InstrRev arguments are (string1, string2, start, compare).
· The Instr function has been around since the earlier days of BASIC, whereas InstrRev was not introduced until VB 6.
· Built-in "vb" constants can be used for the compare argument:
vbBinaryCompare for 0 (case-sensitive search)
vbTextCompare for 1 (case-insensitive search)
Function: |
String$ (or String) |
Description: |
Returns a string containing a repeating character string of the length specified. |
Syntax: |
String$(number, character) The String$ function syntax has these parts: number Required; Long. Length of the returned string. character Required; Variant. This argument can either be a number from 0 to 255 (representing the ASCII character code* of the character to be repeated) or a string expression whose first character is used to build the return string. |
Examples: |
|
* A list of the ASCII character codes is presented at the end of this topic.
Function: |
Space$ (or Space) |
Description: |
Returns a string containing the specified number of blank spaces. |
Syntax: |
Space$(number) Where number is the number of blank spaces desired.
|
Examples: |
|
Function: |
Replace$ (or Replace) |
Description: |
Returns a string in which a specified substring has been replaced with another substring a specified number of times. Introduced in VB 6. |
Syntax: |
Replace$(expression, find, replacewith[, start[, count[, compare]]]) The Replace$ function syntax has these parts: expression Required. String expression containing substring to replace. find Required. Substring being searched for. replacewith Required. Replacement substring. start Optional. Position within expression where substring search is to begin. If omitted, 1 is assumed. count Optional. Number of substring substitutions to perform. If omitted, the default value is –1, which means make all possible substitutions. compare Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. (0 = case sensitive, 1 = case-insensitive) Built-in "vb" constants can be used for the compare argument: vbBinaryCompare for 0 (case-sensitive search) |
Examples: |
|
Function: |
StrReverse$ (or StrReverse) |
Description: |
Returns a string in which the character order of a specified string is reversed. Introduced in VB 6. |
Syntax: |
StrReverse$(string) |
Examples: |
|
Function: |
LTrim$ (or LTrim) |
Description: |
Removes leading blank spaces from a string. |
Syntax: |
LTrim$(string) |
Examples: |
|
Function: |
RTrim$ (or RTrim) |
Description: |
Removes trailing blank spaces from a string. |
Syntax: |
RTrim$(string) |
Examples: |
|
Function: |
Trim$ (or Trim) |
Description: |
Removes both leading and trailing blank spaces from a string. |
Syntax: |
Trim$(string) |
Examples: |
|
Function: |
Asc |
Description: |
Returns an Integer representing the ASCII character code corresponding to the first letter in a string. |
Syntax: |
Asc(string) |
Examples: |
|
Function: |
Chr$ (or Chr) |
Description: |
Returns a string containing the character associated with the specified character code. |
Syntax: |
Chr$(charcode) Where charcode is a number from 0 to 255 that identifies the character. |
Examples: |
|
ASCII Character Codes (0 through 127)
0 |
N/A |
32 |
[space] |
64 |
@ |
96 |
` |
1 |
N/A |
33 |
! |
65 |
A |
97 |
a |
2 |
N/A |
34 |
" |
66 |
B |
98 |
b |
3 |
N/A |
35 |
# |
67 |
C |
99 |
c |
4 |
N/A |
36 |
$ |
68 |
D |
100 |
d |
5 |
N/A |
37 |
% |
69 |
E |
101 |
e |
6 |
N/A |
38 |
& |
70 |
F |
102 |
f |
7 |
N/A |
39 |
' |
71 |
G |
103 |
g |
8 |
(backspace) |
40 |
( |
72 |
H |
104 |
h |
9 |
(tab) |
41 |
) |
73 |
I |
105 |
i |
10 |
(line feed) |
42 |
* |
74 |
J |
106 |
j |
11 |
N/A |
43 |
+ |
75 |
K |
107 |
k |
12 |
N/A |
44 |
, |
76 |
L |
108 |
l |
13 |
(carriage return) |
45 |
- |
77 |
M |
109 |
m |
14 |
N/A |
46 |
. |
78 |
N |
110 |
n |
15 |
N/A |
47 |
/ |
79 |
O |
111 |
o |
16 |
N/A |
48 |
0 |
80 |
P |
112 |
p |
17 |
N/A |
49 |
1 |
81 |
Q |
113 |
q |
18 |
N/A |
50 |
2 |
82 |
R |
114 |
r |
19 |
N/A |
51 |
3 |
83 |
S |
115 |
s |
20 |
N/A |
52 |
4 |
84 |
T |
116 |
t |
21 |
N/A |
53 |
5 |
85 |
U |
117 |
u |
22 |
N/A |
54 |
6 |
86 |
V |
118 |
v |
23 |
N/A |
55 |
7 |
87 |
W |
119 |
w |
24 |
N/A |
56 |
8 |
88 |
X |
120 |
x |
25 |
N/A |
57 |
9 |
89 |
Y |
121 |
y |
26 |
N/A |
58 |
: |
90 |
Z |
122 |
z |
27 |
N/A |
59 |
; |
91 |
[ |
123 |
{ |
28 |
N/A |
60 |
< |
92 |
\ |
124 |
| |
29 |
N/A |
61 |
= |
93 |
] |
125 |
} |
30 |
N/A |
62 |
> |
94 |
^ |
126 |
~ |
31 |
N/A |
63 |
? |
95 |
_ |
127 |
N/A |
N/A = These characters aren't supported by Microsoft Windows.
ASCII Character Codes (128 through 255)
128 |
N/A |
160 |
[space] |
192 |
À |
224 |
à |
129 |
N/A |
161 |
¡ |
193 |
à |
225 |
á |
130 |
N/A |
162 |
¢ |
194 |
 |
226 |
â |
131 |
N/A |
163 |
£ |
195 |
à |
227 |
ã |
132 |
N/A |
164 |
¤ |
196 |
Ä |
228 |
ä |
133 |
N/A |
165 |
Â¥ |
197 |
Ã… |
229 |
Ã¥ |
134 |
N/A |
166 |
¦ |
198 |
Æ |
230 |
æ |
135 |
N/A |
167 |
§ |
199 |
Ç |
231 |
ç |
136 |
N/A |
168 |
¨ |
200 |
È |
232 |
è |
137 |
N/A |
169 |
© |
201 |
É |
233 |
é |
138 |
N/A |
170 |
ª |
202 |
Ê |
234 |
ê |
139 |
N/A |
171 |
« |
203 |
Ë |
235 |
ë |
140 |
N/A |
172 |
¬ |
204 |
Ì |
236 |
ì |
141 |
N/A |
173 |
 |
205 |
à |
237 |
à |
142 |
N/A |
174 |
® |
206 |
ÃŽ |
238 |
î |
143 |
N/A |
175 |
¯ |
207 |
à |
239 |
ï |
144 |
N/A |
176 |
° |
208 |
à |
240 |
ð |
145 |
N/A |
177 |
± |
209 |
Ñ |
241 |
ñ |
146 |
N/A |
178 |
² |
210 |
Ã’ |
242 |
ò |
147 |
N/A |
179 |
³ |
211 |
Ó |
243 |
ó |
148 |
N/A |
180 |
´ |
212 |
Ô |
244 |
ô |
149 |
N/A |
181 |
µ |
213 |
Õ |
245 |
õ |
150 |
N/A |
182 |
¶ |
214 |
Ö |
246 |
ö |
151 |
N/A |
183 |
· |
215 |
× |
247 |
÷ |
152 |
N/A |
184 |
¸ |
216 |
Ø |
248 |
ø |
153 |
N/A |
185 |
¹ |
217 |
Ù |
249 |
ù |
154 |
N/A |
186 |
º |
218 |
Ú |
250 |
ú |
155 |
N/A |
187 |
» |
219 |
Û |
251 |
û |
156 |
N/A |
188 |
¼ |
220 |
Ü |
252 |
ü |
157 |
N/A |
189 |
½ |
221 |
à |
253 |
ý |
158 |
N/A |
190 |
¾ |
222 |
Þ |
254 |
þ |
159 |
N/A |
191 |
¿ |
223 |
ß |
255 |
ÿ |
N/A = These characters aren't supported by Microsoft Windows.
The values in the table are the Windows default. However, values in the ANSI character set above 127 are determined by the code page specific to your operating system.
"Try It" Example
To demonstrate the built-in string functions, set up a "Try It" project, and place the following code in the cmdTryIt_Click event:
Some tips on what to enter:
You can also modify the code and run the project to see if you get the results you expect.
The screen shot below shows a run of the project using the code above where the string Visual Basic was input:

Download the VB project code for the example above here.
Comments
great post,super blog. Made
great post,super blog. Made exercises. Help a lot. Thanks
hi i have a problem in
hi i have a problem in getting the acronym in visual basic using the string....
Additional exercises chapter 4 pg 89 of the workbook
hi,
i cant figure out the code to read in reverse. i would really like some help with it.
thank you.
VB6
what code that allow the user to search the details about the word..for example, i want to search the name of singer specifically Regine Velasquez....then it will display her albums and when it was publish..the output comes out in listbox...thx for ur help ahead...
simply understandable!!!!
This page is really nice and helped me a lot to know the use of code and how to use those code in our program. Thanks for doing this excellent job.
MS Access form filter
How can I limit records used in a form to field starting with "S"?
hey
how to search a record even if the record that you are finding is in proper case and you type in the searchtxtbox a lower or uppercases entries?
writing frequency codes
can someone hel with frequency code for VB Program, urgent pls
help
can u help me with the frequency codes in Vb
hi all, im a new
hi all,
im a new in vb6 and im working with a program that uses database could someone helpme on how to link the database access
in corresponding textbox same as when im adding data in vb6 gui it will save on my database using a command? any responce
was greatfully appriciated..
response
try these sites.
www.vbexplorer.com
www.vbtutor.net
There are several ways to connect your form to a database..
through:
DAO "the most basic"
ADODC
Would you like to help me.
Would you like to help me. how to make mirror text in vb6..thank's before..
Im in the middle of making
Im in the middle of making my program, It is where u count the number of characters in a 2 certain textbox like the Len function and then u add their sum which will show in another textbox . What code should i use in the command button? HELP ASAP! TNX,
EXCELLENT
EXCELLENT
need help parsing strings
hello all,
please show me how to display the comma separated string : "abc, 345-101,tr-987" .
in my program, im entering the value into a textbox, using the split() function im splitting based on " , "
code:
Dim values As String
values = TextBox1.Text
Dim str As String() = Nothing
str = values.Split(",")
My problem is i dunno how to show the separated parts of the string into 3 different textboxes... TextBox2 and TextBox3 and Text TextBox4.
Thankyou!
How to use split
Dim Values As String 'Values is a string inputValues = TextBox1.Text
Dim str as Variant 'str however is an Array() so we declare it as Variant
str = Split(Values,",") ' Split Values by the comer value ,
Text1 = str(0) 'Now we can assign the textboxes values.
Text2 = str(1) 'Remember an Array() always starts from 0
Text3 = str(2)
Text4 = str(3)
Enjoy
Pretty cool! I use this
Pretty cool!
I use this string length tool to get the length of a string, pretty useful!
David
Thank you!
Wow, it accelarates my VBA-skills tremendeously! Thanks for the efforts!
How to read the filename from the pathname
Hi,
I wanted to read the filename from a pathname. For, example:
Pathname: "C:\Users\Admin\Desktop\Wrk\Virtual Graphs\VB Work\Work from Sep 09\Projection.img"
I need to get the filename "Projection"
Please help.
How to use split
Again,,,
Dim PathName as string 'Define your original path as a stringDim PathBroken as Variant 'Array for braking your path into pieces
Dim FileName as Variant 'The end result filename you so desire :P
PathName = "C:\Users\Admin\Desktop\Wrk\Virtual Graphs\VB Work\Work from Sep 09\Projection.img"
PathBroken = Split(pathName, "\") 'Split the Path by \
'Now we want the last piece of the data in PathBroken so
'we use Ubound() which tells us the amount of pieces in the split array
'So we get PathBroken( the last piece)
'for further note Lbound() returns the first piece
FileName = PathBroken(Ubound(PathBroken))
:)
How to read the filename from the pathname
we gat the path as Pathname: "C:\Users\Admin\Desktop\Wrk\Virtual Graphs\VB Work\Work from Sep 09\Projection.img"
so use the InstrRev with yer path . ie,
Strlen = Len(pathname)
Intpos = InstrRev(pathname,"\")
Intlens = len - Intpos
filename = Mid(pathname,Intpos,Intlens)
MsgBox "Hurraaaayy we gat the file name : " &filename
now filename = "\Projection.img" enjoy !
Unicode
Can anybody help? I want to make Unicode character (like Chr(Number) but in unicode).
help me
please help me to make a program of a material directory system using vb and database
in a warehouse of an electronic company
can someone here help
can someone here help me...
i need a codes for log in system with ms access database for vb6 with multiple users..send to my email pls....
gurl_lovely_28@yahoo.com
com
I want
Counter...
Hi, my name is Mike and I am looking for code that will count the letters in a text box, then display the number of characters in a label. Please help me out. Thanks.
Its to easy..........
Assume ....
You have a textbox named text1, and a label named label1.
Then write this code in the change event of the textbox.
label1.caption=str(len(me.text1.text))
if you don't want to count the left spaces then.
label1.caption=str(len(trim(me.text1.text)))
Thank you......
If you want more i will help you. Just mail me..... kingsonprisonic@gmail.com
Label1.Caption =
Label1.Caption = Len(Textbox.text)
Solution
Label1.Caption = Len(Textbox.text)
Please mail me how to modify registry with vb 6.0
Help!!!!!!!!!
Please write a program to modify registry and send me coding for this program and how to write
VB6 Registry Functions
VB6 has its own set of registry functions. Search in VB6 Help.
To convert string into
To convert string into Upercase the first letter and lowercase the rest:
Dim str As String
str="san diego"
StrConv(str, vbProperCase)
= "San Diego"
Hey, thanks this helpful
Hey, thanks this helpful documents.
you did a good work.
Limit number characters in one line of text file
I Need help!
I have a tring as "I am working on a new assignment with Visual basic 6.0 AAAAAAAAAAAAAAAAAAAAAA"
I try to split the string in Text file; each line have no more than 15 characters; first, split the string at space not in word; second, the word is longer than 15, split the word. How can I make the output as the one below:
I am working
on a new
assignment with
Visual basic
6.0
AAAAAAAAAAAAAAA
AAAAAAA
Please help, Thanks a lot...
try this
if u are using a textbox, it's just simple, just go to the properties of text box then set the max length to 15 and then set the multiline to true. i hope i'd help you even it's to very late. hehehe
Extracting data till the end
I want to extract data through VB code. We have a mail and the mail body content is stored in a stord in a string. there is tag called "description". Description data is a string, with no specific length. We want to extract that data.
Currently its giving the data but truncating some where in the middle and so am not getting the complete text present in 'description' tag/
Any suggestions as how can we do it.
Thanks
how to find that the perticular character in a string in null.
hi good morning, is the string for example. 8th character is null but how to find out.
answer
gumagamit kba ng database d2
ok kung sa database
this code...
with adodc1.recordset
.movefirst
do while not .eof
if text1.text="" and len(text1.text)=8 then
exit sub
end if
.movenext
loop
end with
comparision of two arrays
Hi the content of this article was so good and useful...i want to know how v will compare or search for one item in one array with the another array
for example :
array a consists of 1,2,3,4,5
array b consists of 2,5, 7, 9
now i want to compare array a and b and need to get a mesage box as 2 and 5 exists in array a
so anyone can please help me in this....
the soulution of ur problem
example.... .but convert into a text
ok first
dim a as integer
dim s as string
a=a+1
s=text2.text
for a=1 to len(text1)
if instr(text2.text,text2.text) then
msgbox s & "existing number"
s=mid(s,a,1)
end if
next
take note you must convert into array
answer
ok in a msgbox you must variable the number exist example
if a=b then
msgbox a & b & "is already exist"
else
exit sub
end if
like dat' ok later....i will give you a programm like dat'''
dim i, k, x as interger dim
dim i, k, x as interger
dim arrayC as integer
x = 0
for i=0 to ubound(arrayA)
for k=0 to ubound(arrayB)
if arrayB(k) = arrayA(i) then
arrayC(x) = arrayB(k)
x = x + 1
end if
next
next
arrayC will contain values that are repeated in both arrays. (ie for the example arrays you provided arrayC will contain (2,5)
thank you
thank you
need an equivalent to
need an equivalent to foxpro's padleft?
Code for seprtate character And Number from String
the below code remove the character and number indiviually due to that we can easily seprated the numbers and string...
code as below
Dim revs As String
Dim str1 As String
Dim str2 As String
revs = StrReverse(txtChanginItemCode.Text)
str2 = StrReverse(Val(revs))
str1 = StrReverse(Replace(revs, StrReverse(str2), ""))
references needed for string functions
In vb6 do I need to include any references to allow me to use these string functions.
Too Helpful
The information contained therein is very helpful both as reference or for reading and study purposes. This should be awarded SITE OF TE YEAR 2009. :)
Charles
check for particular string against a set of values
i need to check for a particular string against a set of string values:Can anybody help me in this
eg:-
If arrayCol(k, 0) <> "do" or "jo" or "uo" Then
MsgBox "Department cannot be Null. Line No. " & totItems, vbCritical, "ALERT"
Else
----
Try this
If arrayCol(k, 0) = "do" or arrayCol(k, 0) = "jo" or arrayCol(k, 0) = "uo" Then...
Else
MsgBox "Department cannot be Null. Line No. " & totItems, vbCritical, "ALERT"
End If
Hey, how would I
Hey, how would I "CONCATENATE" in VB?
Say I need to add "A" to the beginning of the string in Cell A1 and then loop it till the end.
Thanks in advance!
Operator & or +, avaible in help file
& or +
"the cat" & " the hat" = "the cat the hat"
Var = "file"
Var & ".dat" = "file.dat"
Network Security
Article is quite nice . covers all functions related to string ,
VB codes
\Yuyour site is really helpful. please send me a complete list and the codes used in VB and its function.
Thathank you very much.
How can i select a string between eg. <!--- and -->
Hi to all,
How can i select a string between eg.
str1= function(<"!--There is a comment-->")
str1 should give me "There is a comment"
Yours sincerely,
Walky Talky
how to select string between fixed prefix and suffix
if the prefix and suffix are fixed, it would be much easier to do this:
str1 = mid([comment],5,len(comment)-9)
where:
comment -> the manipulated comment (the whole string)
5 -> the position in which the comment text starts
len(comment)-9 -> the length of the whole comment less the prefix+suffix. results with the text length.
hope it was helpful
' Create a Function called
' Create a Function called GetComment(), uses a variable called MyString as a String
' Function GetComment() Returns a String
' By Asaf Ayoub
Function GetComment(MyString As String) As String
Dim pos1 As Integer, pos2 As Integer
' Find position 1 from start of string
pos1 = InStr(1, MyString, "<!--")
' Find position 2, starting from pos1
pos2 = InStr(pos1, MyString,"-->")
' return string of MyString, starting at pos1 + 4 characters of first search string
' copy characters, until difference of positions of both strings positions (pos2-pos1)
' minus 4 for second search string length.
GetComment = Mid$(MyString, pos1 + 4, pos2 - pos1 - 4)
End Function
str1 = GetComment("<!--There is a comment-->")
Debug.Print str1
Need help
thanks for this article...
But please help me more with trim
I need to extract the content a text box and save it in an array
For example:
(textbox content): 12 34 567 89 45
i need to save it in array in() where
in(0) = 12
in(1) = 34
in(2) = 567
in(3) = 89
in(4) = 45
values inside the array will depend on the spaces
Please help me
Thanks in advance
seperatring string
dim textboxcontent as string
dim in
textboxcontent =12 34 567 89 45
in=split(textboxcontent ," ")
now in(0) will show 12
use the split command;
use the split command; Split(expression[, delimiter[, count[, compare]]])
so in your case
in = split(textbox.text,vbspc,-1,vbtextcompare)
bingo, done. see below for details.
Part Description
expression Required.String expression containing substrings and delimiters. If expression is a zero-length string(""), Split returns an empty array, that is, an array with no elements and no data.
delimiter Optional. String character used to identify substring limits. If omitted, the space character (" ") is assumed to be the delimiter. If delimiter is a zero-length string, a single-element array containing the entire expression string is returned.
count Optional. Number of substrings to be returned; –1 indicates that all substrings are returned.
compare Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values.
Settings
The compare argument can have the following values:
Constant Value Description
vbUseCompareOption –1 Performs a comparison using the setting of the Option Compare statement.
vbBinaryCompare 0 Performs a binary comparison.
vbTextCompare 1 Performs a textual comparison.
vbDatabaseCompare 2 Microsoft Access only. Performs a comparison based on information in your database.
Difference between the $ and non-$ functions
You said that you can use, for example TRIM() or TRIM$(), but the TRIM$() would be more efficient. What is the difference, and why is one more efficient than the other?
The non-$ functions are
The non-$ functions are general variant functions. They take in and return variants, so there is some extra processing involved.
The $ functions are string functions. They take in and return strings. This reduces the processing time.
It is best to use the $ functions whenever possible, since they are much faster. The non-$ functions can be used when the data type is not known, or when you need to do this sort of processing with variables that are not strings.
Need Help
I have an error that reads like so: strString(bytI,bytI2)=-1.#IND: what does that mean?
RE: Using Strings
dont know that error man
Using Strings
Im making a program and dont know how to take strings from one form into another without having to use a module...i'd rather not use global variables and strings
YOU CAN USE BACK-END TOOLS
YOU CAN USE BACK-END TOOLS LIKE ACCESS , ORACLE, MYSQL SERVER, ETC
Thanks
This page on string functions really helped me out, for the first month or so when i started using Visual Basic 6, I was terribly lost but this page on strings definitely turned things around for me. Thanks a million.
How to use the string function on a textbox
thnk you so much for the information you show on this site it really help me..
there is some things that i want to try... like for example i would like to use the sting function on a textbox.... hope u email me soon... thnx
confused
I want to know how in a textbox how you disable the letters so only numbers can be entered into the box.
Try declaring the textbox as
Try declaring the textbox as an integer
Re: String in VB6
I have a problem that when I set language option (Advance) to any asia language other than English in control panel, I am not able to use all the ASCII characters, I can only use half of it in VB6,(asc value from 1 to 128 only), any character with asc value > 128 will become 0 automatically.
Any one can help ?
Post new comment