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
Sending a string through mscomm
Hello,
I would like to know how i can send a string like 4352119 out of the serial port at a baud rate of say 9600. How is it going to be sent? Are they going to be sent out individually, like 4 will be sent out followed by 3 and so on, with a start and stop bit for each one ? I'm using VB6
MSComm1.Output = "4352119"
Find string
Very new to VB. Need code to copy the string that follows "PMT INFO:TRN*1*" to the next * to a cell right beside this data field in excel. So would need 123456789 in the example below. The number of characters to return will vary and in some cases will not be present at all. The number of rows to search will also vary. Please help...
Payor Name DES:CUSTEFTS ID:XXXXX2061 INDN:Practice Name CO ID:1066033492 CCD PMT INFO:TRN*1*123456789*555555555- 44345 0341 12/30 UNPOSTED NO REASON. CN
help pls
in textbox i use this code
Private Sub Text1_Change()
' Allow only numbers."
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim ch As String
ch = Chr$(KeyAscii)
If Not (ch >= "1" And ch <= "4") Then
' Cancel the character.
KeyAscii = 0
End If
End Sub
but i cand use delete or backspace....
pls help me i need to use the delete or backspace.????? thanks
help pls
in textbox i use this code
Private Sub Text1_Change()
' Allow only numbers."
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim ch As String
ch = Chr$(KeyAscii)
If Not (ch >= "1" And ch <= "4") Then
' Cancel the character.
KeyAscii = 0
End If
End Sub
but i cand use delete or backspace....
pls help me i need to use the delete or backspace.????? thanks
Private Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
Dim ch As String
ch = Chr$(KeyAscii)
If Not (ch >= "1" And ch <= "4") Then
' Cancel the character.
If KeyAscii >= 32 Then ' checks for control keys
KeyAscii = 0
End If
End If
End Sub
Hope this helps : )
Hello... Anybody there to help me please
I would like to copy from a access table to another table ( two text value )
vertdb.Execute "insert into osdbox(clid,byval,sellval,qty,rate,hcp,phbyval,scode,scrip)values('" & rsm4!clid & "'," & rsm4!byval & "," & rsm4!sellval & "," & rsm4!qty & "," & rsm4!Rate & "," & rsm4!hcp & "," & rsm4!phbyval & ",'" & rsm4!scode & "'," & " '," & rsm4!scrip & "')"
the problem is before scrip(test value) ' is comming .
please give me the correct command to remove ' symbol from scrip
2 know about string functions
i want 2 know a brief description about string functions....................................
How to avoid "&" character to interrupt string.
I have a VBA code which allows me to pick fields from a DB and send email.
It sounds like: Me.Email.HyperlinkAddress = "mailto:" & RecipientName & "<" & RecipientAddress & ">"
The problem is that if the RecipientName field has the "&" character in it, the string is truncated at that point.
I have tried to use Replace and Format functions with Chr(38) code, but without success.
How can I do? Thank you.
Test
Sub CheckTCNumber()
Dim Count As Integer
Dim Num As Integer
Dim LastRow As Integer
Dim TCString As String
Dim TCScenario As String
LastRow = ActiveSheet.UsedRange.Rows.Count
Num = 1
Count = 1
For rwNumber = 3 To LastRow
If ActiveSheet.Cells(rwNumber, 1).Value <> "" Then
If Count < 10 Then
TCString = "TC00" + Trim(Str$(Count))
Else
TCString = "TC0" + Trim(Str$(Count))
End If
ActiveSheet.Cells(rwNumber, 1).Value = TCString
Count = Count + 1
TCScenario = ActiveSheet.Cells(rwNumber, 6).Value
Mid$(TCScenario, 1, 5) = TCString
ActiveSheet.Cells(rwNumber, 6).Value = TCScenario
End If
Next rwNumber
MsgBox "Test case number checked"
End Sub
Help Me Please
Dear Friends
I m new in vb 2005. i want that
1. i have to enter a sentence to a text field and when i press a button then my given sentence will split into words and replace these words from mysql database
example: i have entered "i am fine and ok"
then "i" will be converted to "eye"
"am" to "m"
"fine" to "f9"
"and" to "n"
"ok" to "okay"
and this show sentence again "eye m f9 n okay" on text field
but these words and replacing words will be taken from mysql database
Please help me sir .......
regards :::: it eagle
if your database includes
if your database includes "firstword" and "secondword".. for example "I" and "eye"..
then you have to write down the whole database into an array.. like firstword() and secondword()
so you can just say: "
for i = 0 to count(firstword)
strString = replace(strString, firstword(i), secondword(i))
next
"
the result will be : "eye m f9 n okay"!
Very useful site
Hi......All
Thai is S.S.Sahoo. i am working as a software engg.
today i vought this site through google.
& I found that this is a best site for those who want to learn some thing.
And also i learnt a lot from this site........i will definitely use this site for learn more.& suggest you people to go through this site & spend some time ,if u r serious .
Thanks
Jipu
hi i want to search a name
hi i want to search a name which is of length aroung 40 character from a sql database using the recordset .
plz help me
i just needed it for my project
Thanks a lot for this
Thanks a lot for this information on VB string functions.
HELPPPPP
gr8 tutorial but i need some help...i want to manipulate each character separatly entered in the textbox....actually i want to rite a ceaser cipher algo in VB n so for that i have to consider each character separately...kindly help me out on how to do it....thx
Do your own work you dork!
You're assigned homework for a purpose. Spend the time to learn how to do your assignment yourself.
Although...If you can't even spell "write" correctly you're probably screwed anyways.
comments
wow! this page has been really useful for me. in this single page i got all the notes which i required about string functions. thanks a lot to the writer.
Hi All, I have an
Hi All,
I have an assignment where I have to validate a password using the IsValalid function which should accept a string as its argument and return a Boolean value. The password must be at least 6 characters long and have at least one numeric digit and at least one alphbetic character. If the password is valid, the function should return True. Otherwise, it should return false. Any help would be greaty appreciated. Right now I have the design set for input to be in an inputbox but am lost how to accomplish all these validations. Thanks in advance!
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 ,
Post new comment