Visual Basic 6 String Functions

Level:
Level2

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:

lngLen = Len("Visual Basic")    ' lngLen = 12

 

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:

 

strSubstr = Mid$("Visual Basic", 3, 4)          ' strSubstr = "sual"

Note: Mid$ can also be used on the left side of an assignment statement, where you can replace a substring within a string.

strTest = "Visual Basic"
Mid$(strTest, 3, 4) = "xxxx"

'strTest now contains "Vixxxx Basic"

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:

strSubstr = Left$("Visual Basic", 3)      ' strSubstr = "Vis"

' Note that the same thing could be accomplished with Mid$:
strSubstr = Mid$("Visual Basic", 1, 3)

 

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:

strSubstr = Right$("Visual Basic", 3)     ' strSubstr = "sic"

' Note that the same thing could be accomplished with Mid$:
strSubstr = Mid$("Visual Basic", 10, 3)

 

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:

strNew = UCase$("Visual Basic")           ' strNew = "VISUAL BASIC"

 

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:

strNew = LCase$("Visual Basic")           ' strNew = "visual basic"

 

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:

lngPos = Instr("Visual Basic", "a")
' lngPos = 5

lngPos = Instr(6, "Visual Basic", "a")
' lngPos = 9       (starting at position 6)

lngPos = Instr("Visual Basic", "A")
' lngPos = 0       (case-sensitive search)

lngPos = Instr(1, "Visual Basic", "A", 1)
' lngPos = 5       (case-insensitive search)

 

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:

lngPos = InstrRev("Visual Basic", "a")
' lngPos = 9

lngPos = InstrRev("Visual Basic", "a", 6)
' lngPos = 5 (starting         at position 6)

lngPos =       InstrRev("Visual Basic", "A")
' lngPos = 0         (case-sensitive search)

lngPos =       InstrRev("Visual Basic", "A", , 1)
' lngPos = 9         (case-insensitive search)
' Note         that this last example leaves a placeholder for the start argument

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:

strTest = String$(5, "a")
' strTest = "aaaaa"

strTest = String$(5, 97)
' strTest = "aaaaa" (97 is the ASCII code for "a")

* 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:

strTest = Space$(5)     ' strTest = "     "

 

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)
vbTextCompare for 1 (case-insensitive search)

Examples:

strNewDate = Replace$("08/31/2001", "/", "-")
' strNewDate = "08-31-2001"

 

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:

strTest = StrReverse$("Visual Basic")           ' strTest = "cisaBlausiV"

 

 

Function:

LTrim$ (or LTrim)

Description:

Removes leading blank spaces from a string.

Syntax:

LTrim$(string)

Examples:

strTest =         LTrim$("  Visual Basic  ")
' strTest =         "Visual Basic  "

 

Function:

RTrim$ (or RTrim)

Description:

Removes trailing blank spaces from a string.

Syntax:

RTrim$(string)

Examples:

strTest = RTrim$("Visual Basic")      ' strTest = "Visual Basic"

 

Function:

Trim$ (or Trim)

Description:

Removes both leading and trailing blank spaces from a string.

Syntax:

Trim$(string)

Examples:

strTest = Trim$("  Visual Basic  ")       ' strTest = "Visual Basic"
' Note: Trim$(x) accomplishes the same thing as LTrim$(RTrim$(x))

 

Function:

Asc

Description:

Returns an Integer representing the ASCII character code corresponding to the first letter in a string.

Syntax:

Asc(string)

Examples:

intCode = Asc("*")      ' intCode = 42
intCode = Asc("ABC")    ' intCode = 65

 

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:

strChar = Chr$(65)     ' strChar = "A"

 

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:

Private Sub cmdTryIt_Click()
    Dim strTest As String

    strTest = InputBox("Please enter a string:")

    Print "Using Len:"; Tab(25); Len(strTest)
    Print "Using Mid$:"; Tab(25); Mid$(strTest, 3, 4)
    Print "Using Left$:"; Tab(25); Left$(strTest, 3)
    Print "Using Right$:"; Tab(25); Right$(strTest, 2)
    Print "Using UCase$:"; Tab(25); UCase$(strTest)
    Print "Using LCase$:"; Tab(25); LCase$(strTest)
    Print "Using Instr:"; Tab(25); InStr(strTest, "a")
    Print "Using InstrRev:"; Tab(25); InStrRev(strTest, "a")
    Print "Using LTrim$:"; Tab(25); LTrim$(strTest)
    Print "Using RTrim$:"; Tab(25); RTrim$(strTest)
    Print "Using Trim$:"; Tab(25); Trim$(strTest)
    Print "Using String$ & Space$:"; Tab(25); String$(3, "*") _
        & Space$(2) _
        & Trim$(strTest) _
        & Space$(2) _
        & String$(3, 42)
    Print "Using Replace$:"; Tab(25); Replace$(strTest, "a", "*")
    Print "Using StrReverse$:"; Tab(25); StrReverse$(strTest)
    Print "Using Asc:"; Tab(25); Asc(strTest)
End Sub

Run the project and click the "Try It" button. When the input box comes up, enter a string of your choice.

 Some tips on what to enter:

  • To see the effects of UCase$ and LCase$, enter a mixed case string.
  • To compare Instr and InstrRev, enter a string with at least two "a"s in it.
  • To see the effects of LTrim$, RTrim$, and Trim$, enter a string with leading and/or trailing spaces.
  • To see the effect of Replace$, enter a string with at least one "a" in it.

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.

VBA String Functions

An important thing to note is that all of these functions also work with Visual Basic for applications. When working with the VBA string functions you will call them in the exact same way as the samples discussed in this article. For example if you want to find the length of a string in VBA you would use this: Len("somestring"). If you run into any issues doing this please post a comment below.

Originally Written By TheVBProgramer. Cleaned up and reformatted for this site.

If you enjoyed this post, subscribe for updates (it's free)

String Manipulation

Hi everybody...

I want to make one program with First, Second and Last name function..

For Example:
I use this name : Text1.text = Chaudhry Waqas Vicky

and I need this name to be show as

Your First Name = Chaudhry
Your Second Name = Waqas
Your Last Name = Vicky

Please if anyone know about this plz let know,,,

ch.vicky7779@gmail.com

Advance Thankz.

hay

if the input 23x1,216x11,1252x32 then I want the sorted according digit before x then the data is entered into the database.

I want to eventually look like this

2 digits x 3 digits x 4 digit x
23 1 216 11 1252 32

please send me email or you can answer it here.
thanks before.

How to use Vbpropercase?

Ucase and Lcase is working but i dont know how to use vbProperCase what is the code for that?

Example: I type "hello luna" it will automatically goes like this "Hello Luna"
after you click spacebar or after you press (.) it will make the first letter of the word Uppercase

Please help me. . .

This page is Interesting

who like programming? I am new in this page and as i read all the comments,questions and answers very interesting, What can i say is "who surf this page is a lucky one "thank you so much it helps me a lot . . .

i want to search string in

i want to search string in sentence example

name = lina
sentence = lina was eating fried chicken

i want to search string lina in sentences. how to do that if i have more than one sentences

Dim k As String k =

Dim k As String
k = "lina was eating fried chicken"
Dim f As String
f = "lina"
Dim f1 As String
f1 = Left(k, 4)
Console.WriteLine(f1)
Console.ReadKey()

STX and ETX in vb6

Hi,
We are working with vb6 and need to send an data to an intrument through serial port
data format looks like below
start of text +data + end of text [start of text(02) and end of text (03)are ASCII codes]
when we enter the keyshort of start of text(Alt +2) and end of text (Alt+3), it display like '?" and vb6 showing error
could some one help, how to can add STX and ETX while sending data through serial port?
Deeply appreciate all the replies!
Thanks

Use Chr() for ASCII Control Codes

STX and ETX are ASCII control codes (they are un-printable on screen, and your keyboard has keys on it for sending printable characters, and these aren't printable, so the operating system maps them to "?").

You can use Chr(2) for STX and Chr(3) for ETX.

Dim strMsg As String
strMsg = Chr(2) & "Hello World!" & Chr(3)

Visual Basic

Dear All,

I am beginner in VB6, i am making a small sized application for my company. for example. MAC Address which is come as 00:00:00:00:00:00
, if i type characters into textbox like 000000000000, the output format should be come as MAC Address format above mentioned.

could you please help me in this regard and I look forward your reply.

Regards,
Seyed Ismail

try using this

try using this function:

format (txtToFormat, "00:00:00:00:00:00")

try this function FORMAT(txt,

try this function
FORMAT(txt, "00:00:00:00:00:00")

Mac Thing

Shouldn't you just add some code telling the program to insert a colon every 2 digits

Within a word

How do you find a single character within a word. For example, finding the letter "e" in the word "epicentre".

How do you find a single

How do you find a single charater in a word like finding an "e" in the word "cheese"?

How to save the number

I have a text file that containing
N10 G00 X20 Z2;
N20 G01 X18;
N30 G01 X18 Z-10;
I already open the text file through list box. But I need to extract the number from the string (N,G,X,Z) an stored as variable. How to do it? thank you

im kinda confused in how to

im kinda confused in how to convert words into ascii. you enter a word than u click convert and it converts it to ascii. for example, wood w=119 o= 111 o= 111 d= 100. i gotta do this with the whole alphabet

You have to loop char by char

You have to loop char by char getting the individual Ascii value of the text you want to convert,
for example in vb6:

Dim sValue as String
dim sAsciiResult as string

sValue = "wood"

for x=0 to len(sValue)
sAsciiResult = Asc(mid(sValue,x, len(sValue) ))
Debug.Print sAsciiResult
loop

Note: This is an example where the vba string function is the same as the vb6 one.

im kinda confused in how to

im kinda confused in how to convert words into ascii. you enter a word than u click convert and it converts it to ascii. for example, wood w=119 o= 111 o= 111 d= 100. i gotta do this with the whole alphabet

how i can print second part

how i can print second part of name incloud three part by mid,instr,left,right function ?

To avoid duplication of character

tnx men....
it's help me to avoid duplication of characters
specially on amount sample: 253.30.1 it is wrong
it must be 253.50 only

here's my code I got an idea from your code...

Dim x
Private Sub txt1_Change()
x = InStr(txt1, ".")
End Sub
Private Sub txt1_KeyPress(KeyAscii As Integer)
If KeyAscii = 46 Then
If Not x = 0 Then
KeyAscii = 0
End If
End If
End Sub

awesome

awesome

Hi, I'm unable to find the

Hi,
I'm unable to find the difference between functions with and without $,some thing like Strng() and String$(). plz give rep asap.

programming book for beginners

i will be grateful if someone can help me access a programming book. i am a novice in this field but have much interest in the subject recently. counting on you.

Programming Book

In google search for "Visual Basic Course Notes by Lou Tylee". You'll eventually find the book. This book is simply awesome.

visual basic

please. i am eager to know programming but no matter how I try I really cant understand any of the codes.

validation

hi,i would like to know,how do you validate a piece of string:
lets say the user is required to enter a string of 10 letters which are between a-f.(eg aaaaffbced)
And the program is required to check to see if each letter that the user has typed is within the a-f range so that if the input contains an out of range letter(eg aaagwsdfee) the program can then display an error message (eg msgbox("please enter letters that are in a-f range")
PLEASE HELP ME.

HI,PLS HELP ME

,i hiwould like to know,how do you validate a piece of string:
lets say the user is required to enter a string of 10 letters which are ACGT.(AAAAACCCGGGTTTTAGCTCCCGG)
And the program is required to check to see if each letter that the user has typed is within the a-f range so that if the input contains an out of range letter(AAASGGTCC) the program can then display an error message (eg msgbox("please enter letters that are in a-f range")

string program in VB

hi...
program to find similar characters in a string and position of the characters. Ex: If the string is "Excellent" output should be there are 3 "e" and the position of the each "e"

Vb6 String Operation

Hi there, i want to remove a blank space between more than words how can i achieve that in vb6
example:
word="Visual Basic"

i want it to become
word="VisualBasic"

outstanding info available

this is a comprehensive knowledge abt string functions you have posted.

Require at least one letter and number in text box

Trying to do validations for a password and the only part I am stuck on is checking the text box for both alpha and numberic characters. There must be at least 1 letter and at least 1 number. Planning for the possibility of complex passwords, I would like to not limit to only alpha numeric and also accept special characters. But for now at least just validate that the text box is alpha numeric. Thanks in advance.

Try This

Text1.text = "AbC1"

Private Sub Command1_Click()
For x = 1 To Len(Text1.Text)
If Asc(Mid(Text1.Text, x, 1)) > 47 And Asc(Mid(Text1.Text, x, 1)) < 58 Then
iNumber = True
Exit For
End If
Next x

For x = 1 To Len(Text1.Text)
If Asc(Mid(Text1.Text, x, 1)) > 96 And Asc(Mid(Text1.Text, x, 1)) < 123 Then
iLowerCase = True
Exit For
End If
Next x

For x = 1 To Len(Text1.Text)
If Asc(Mid(Text1.Text, x, 1)) > 64 And Asc(Mid(Text1.Text, x, 1)) < 91 Then
iUpperCase = True
Exit For
End If
Next x

If (iNumber And iLowerCase) Or (iNumber And iUpperCase) Then
MsgBox ("Good Password")
Else
MsgBox ("Bad Password")
End If
End Sub

All of these work as VBA string functions as well.

String to Array of Character

How to convert string to array of characters?

string count

can somebody help me with my project? i need to create a simple system that can count anything that has been typed on textbox

example:

textbox1 (input): 123 asdb46./-76=8
textbox2 (output): 17

the input should be limited to 60 characters only, else it will display "more than 60 characters"

thanks! :)

Hope you got this

Private Sub Text1_Change()
If (Len(Text1.Text) >= 60) Then
MsgBox "60 Characters only accepted", vbCritical, Error
Text2.text=len(Text1.text)
End If
End Sub

VB 6.0

I should not be able to enter any other chaaracters other then numbers in the text box. Am working on VB6.. pls give me the suggestion..

Private Sub

Private Sub text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then KeyAscii = 0
End Sub

hope it will help u..

Only accept numeric data for textbox control

Add control textbox name Text1 to your form
double click on that control, change the event to KeyPress. Copy and paste the code bellow.
Perhaps the code help for you...

Private Sub Text1_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case Asc("0") To Asc("9"), 1 To 31: KeyAscii = KeyAscii
Case Asc("."), Asc(","): KeyAscii = KeyAscii 'In case you are suppose to use formating numeric e.g. 1,234,567.89
Case Else
KeyAscii = 0
End Select
End Sub

storing each character from a textbox in an array

For i = 0 To 9 Step 1
password(i) = Text1.Text
Next
For i = 0 To 9 Step 1
text2.text = text2.text + password(i)
Next

here is the case i want each character entered in the textbox in an array........

String to Array

dim password() as byte
password = Text1.text

Dim i As Long
Text2.Text = vbNullstring
For i = 0 To UBound(password)
Text2.Text = Text2.Text & Chr(password(i))
Next i

Language translation problem

Hi....
I have a Access Database with Emp_Name_Eng field set to text shows the name of employee in English Language.
I want to add new field Emp_Name_Marathi which convert English name to Marathi Language.
If anyone have code for that please send me.

Or send me the code for Conversion of English characters to standard Unicode.

Please Help Me.

Language translation problem

Hi....
I have a Access Database with Emp_Name_Eng field set to text shows the name of employee in English Language.
I want to add new field Emp_Name_Marathi which convert English name to Marathi Language.
If anyone have code for that please send me.

Or send me the code for Conversion of English characters to standard Unicode.

Please Help Me.

Thank You!

I am doing part time BCA. My college notes suck big time. They don't even contain half of the popular and basic functions.
Had it not been for this tutorial on VB6, I wouldn't have managed to even get the basic idea about using VB6.
Thanks! You've been very helpful. : )

HELPPPPPPPPPPP

I have a sulution is:
I want convert string to more string by spcial word
Ex1: Input string to text box is"Test Test|" output is Test Test. But when is not spical "|" then output is "Test or Test"
Ex2: Input is type "Tes?t" then output is replace word "?" by one or nothing word.
Ex3: Input is type "Te_t" then output is replace word "_" by just one every word.

Sorry language English is not well.
Thank you very much

Replace

I know what you meant, its very simple...

Ex1: Input string to text box is"Test Test|" output is Test Test. But when is not spical "|" then output is "Test or Test"
Answer:
Exp1 = Replace("Test Test|", "|", "")

Ex2: Input is type "Tes?t" then output is replace word "?" by one or nothing word.
Answer:
Exp2 = Replace("Tes?t", "?", "",1,1)

Ex3: Input is type "Te_t" then output is replace word "_" by just one every word.
Answer:
Exp2 = Replace("Te_t", "_", "",1,1)

May Allah reward the vb info

May Allah reward the vb info provider with all. I am highly happy that I have gained a lot. I wish so in the future.

datagrid

how to validate data entered in fields of datagrid

Please a little help

I use this code:

Sub Transformare()
For i = 1 To Len(timp)
If Mid(timp, i, 1) = "." Then unu = i: Exit For
Next i
timp2 = Mid(timp, unu + 1, Len(timp) - unu)
For i = 1 To Len(timp2)
If Mid(timp2, i, 1) = "." Then doi = i: Exit For
Next i
doi = doi + unu
If Len(timp) - doi > 3 Then MsgBox "Timp introdus gresit!" & vbCrLf & "Verificati timpii!"
zecimi = Val(Mid(timp, 1, unu - 1) * 6000) + Val(Mid(timp, unu + 1, doi - 1 - unu) * 100) + Val(Mid(timp, doi + 1, Len(timp) - doi))
End Sub
the initial values are from mshflexgrid and are something like this: 2.35.58 time and the code is coverting to miliseconds. what i try to do is if one or more of the initial values are "ABANDON" then the code to skip that row. can someone help me?

Help please!

Hi to all
Please help me.I need urgent code for compare words in two lists in Excel and when one word is repeate in both lists then this word have to be coloured.
Thanks in advance to all

HELPPPPPPPPPPP ASAPPPPPPPPPPPPPPP!

HI! I WANT TO COMPARE MY TXBX1 TO MY TXBX2. IF THE CHARACTERS(EVEN RANDOMIZE) IN TXBX 1 IS DIFFERENT TO TXBX2 THEN THE ANSWER IN TXBX 3 IS NO IF ELSE YES. WHAT ARE THE CODES? ASAP! HELP PLS!

very easy. sort out

very easy.

sort out alphabetically each entry, then compare them to each others.

compare value in text boxes

quick answer coz i dont have time for implementation

Assume you that you have three text boxes:

if txtbox1.text=txtbox2.text then
textbox1.text=yes
else
textbox1.text=no
end if

try that

comparing textboxes

if textbox1.text=text2box.text then
textbox3.text="yes"
else
textbox3.text="no"
end if

reply

if strcomp(text1.text,text2.text)=0 then
text1.text="yes"
else
text1.text="no"
endif

program that only displays those strings begins with letter "b"

how to do a program that reads a series of strings from the user and displays only those strings beginning with the letter "b"

pls write to me statements

pls write to me statements in BASIC
(1) to replace two right characters of the string A$ by "IN"

I want to find the Number in String in VBA macros

Hi Can any one help me to find the number in Alphanumric string in VBA eg. if i hav 12abc then the output will be 12

VAL()

VAL()

find string that ends with a underscore

searching down a listbox for strings that end with an underscore_ .. not sure how to get it to work correctly,can anyone help please?

hope this helps.

'needed:
'text1.text = "text_"
'text2.text = ""
'command button
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Command1_Click()
If Right(Text1.Text, 1) = "_" Then
Text2.Text = "true"
Else: Text2.Text = "False"
End If
End Sub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'hope this helps
Stop

convo game

i want to do a conversation with use of a lable and an iput box
the lable caption says " how are you?"
then the user answers writing in the input box..
i want to be able to determine what he writes sort of like this
if inputbox.text = good, or , fine, or , happy , or ... like using a buch of examples so as not to have to write
a ton of if then statements for each question that I ask the user.

Solution

You could declare the positive expressions and the negative expressions once and then call it over and over again. You could also divide them into other classes.
For example:

-----------------------------
Use this in a module:
-----------------------------

Public Function GetPositiveInput(what As Integer) As String

Select Case what
Case 1
GetPositiveInput = "good"
Case 2
GetPositiveInput = "great"
Case 3
GetPositiveInput = "fine"
End Select
End Function

----------------------------------
To call this, you could use:
----------------------------------

Private Sub Form_Load()
Dim x As String, y As Integer, z As String

x = InputBox("How are you?", "Question")
For y = 1 To 3
z = GetPositiveInput(y)
If x = z Then
MsgBox "lol.. Good day.."
Exit Sub
End If
Next y
End Sub

If you need anymore help contact me here: sakhawat21@gmail.com

Linking record cells

Please bear with me if this is a bit sketchy.
I have a php form that feeds back to a MySQL database. This is then accessed with an Access db.
On the php form I have a dropdown box that has a list of users. When a user selects one of these users it auto fills a linked cell on the form with the users First initial and Surname.
The data is sent along with other selections from the form to a single record in the MySQL db. I then copy the table that this data is held in so I have a backup of the original records and a working copy to make changes to.

My problem is here. If using the Access db to amend the records and a different user is selceted from the dropdown menu the linked cell in the record does not update. The table that populates the dropdown is called Exec_list and has headings Autonumber, Exec_name, email, Tel, Initialed_name.

What I need is to be able to link the dropdown list to the Initialed_name so that if anyone selects another user it updates the Initlialed_name section.

If you require anything else please contact me and I will see what I can do. This section affects about 3-4 other operations in my application so I need help.

Hope you can help in some way.

Dan

Thanks a lot

Thanks a lot for consolidating the string functions. This helped me in building a macro to generate random password.

Pls help

I need to create an application in vb6 to store my cd keys of various softwares. In the text box, i need to automatically add an hyphen(-) after every 5 characters as in usual cd keys. How do i do it n store it in a database. Pls help...

String Search & Replacement with another character

How to search for a character in string in reverse order and replace it with another character?

plshelpme

if we enter the word ESTABLISHMENT , first we check the last character T in the database table if we get it then it will count 1character, if it will not found in the database then leave it, then check the last 2character NT in the data base if found then count 2 character, like this count the whole word and check it in data base table, now we have the counts 1 character, 2 character,... so then replace/delete the largest count of character by the particular character which is present in the database.....
thanku

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

Solution, Did not test, but the idea is correct

Dim NumberAs String
Dim Start As Integer
Dim End As Integer
 
' Select the cell that has the "PMT INFO:TRN*1*" tag, 
objSpread.Application.Cells.Find(What:="PMT INFO:TRN*1*", LookIn:=xlFormulas, _
    LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=True, SearchFormat:=False).Activate
 
    ' The actual  value is on this cell, but some formatting is required to strip the number
    Start = InStr(objSpread.Application.Selection.Value, "PMT INFO:TRN*1*") + 15
    End = InStr(Start, objSpread.Application.Selection.Value, "*")
    Number = Mid$(objSpread.Application.Selection.Value, Start + 1, End - Start)
 
Debug.Print Number

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

Here's the solution

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii > Asc("9") Or KeyAscii < Asc("0") And KeyAscii <> vbKeyBack Then
KeyAscii = 0
End If
End Sub

It works 100%

Keytrapping

try the folowing

'declare this as const at declarations in form
Const vbKeyDecPt = 46

‘Only allow number keys, decimal point, or backspace
If (KeyAscii >= vbKey0 And KeyAscii <= vbKey9) Or KeyAscii = vbKeyDecPt Or KeyAscii = vbKeyBack Then
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub

its easy it will work for sure

dis is my reply

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < 48 Or KeyAscii > 57 Then
KeyAscii = 0
End If

special keys access or catch from the Keydown event of textbox

You will use the KeyDown event to access the back space and delete or other special keys,....:)

try this Private Sub

try this

Private Sub Text1_Change()
If IsNumeric(Text1.Text) = False Then
Text1.Text = ""
End If
End Sub

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

easy to use the sql command :) [Vinay]

vertdb.Execute "insert into osdbox values(select * from other table)"

keep in mind the both tables fields structures are same then the above command will work, be happy...
feel free to ask another question on my email guptavinay.1@gmail.com

2 know about string functions

i want 2 know a brief description about string functions....................................

Nope.avi

Sorry, can't do that. First, you must take the epic journey of learning to spell

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

VB

Dim a As String
Dim b As String
Dim c As String
Dim result As String

result = txt_1.Text
MsgBox Replace(a, b, c)

Example:
a = "Welcome To Visual Basic"
b = "To"
c = "2"

Ans = Welcome 2 Visual basic

Design:
text1 = a
text2 = b
text3 = c

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

Help with searching string functions

This site has shown me lots of shortcuts to string-processing procedures, but before that I used to use the following technique for processing any string or text:
'let's say the text is called; joetext
joetext = "Howdy buddies?"
'the length of the string is joelen
joelen = Len(joetext)
'and then comes addressing each character separately
For I = 1 to joelen
currentchar = Left$(Mid$(joetext, I), 1)
Next I
'now for each round of the loop the character would be stored in currentchar.

That way you can do whatever you want with each character inside the loop mentioned above!

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 input 
Values = 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

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 string
Dim 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.

IN TEXTBOX CHANGE

IN TEXTBOX CHANGE SUB

x=len(textbox#)
label#=x

THE LABEL WILL BE UPDATED EVERY TIME TEXTBOX CHANGES

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