Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2K views

Visual Basic 6 String Functions - Visual Basic 6 (VB6)

VB

Uploaded by

Mohammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views

Visual Basic 6 String Functions - Visual Basic 6 (VB6)

VB

Uploaded by

Mohammad Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Search
VisualBasic6(VB6)

HomeTutorials

VisualBasic6StringFunctions

Level:
VBhasnumerousbuiltinstringfunctionsforprocessingstrings.MostVBstringhandlingfunctionsreturna
string,althoughsomereturnanumber(suchastheLenfunction,whichreturnsthelengthofastringand
functionslikeInstrandInstrRev,whichreturnacharacterpositionwithinthestring).Thefunctionsthatreturnstrings
canbecodedwithorwithoutthedollarsign($)attheend,althoughitismoreefficienttousetheversionwiththedollar
sign.

ThefirsttimeIstartedtryingtounderstandtheVB6stringfunctionsIwassomewhatconfused.Thistutorialwillwalkyou
throughallthedifferentwaysyoucanusVBtohandlestrings.Ifyouarestillconfusedfeelfreetopostacommentand
hopefullywecanhelpgetyouclearedup.Alsotherearemanyotherstringrelatedtutorialsonthissitesofeelfreeto
browsearound.

Function: Len

Description: ReturnsaLongcontainingthelengthofthespecifiedstring

Syntax: Len(string)

Wherestringisthestringwhoselength(numberofcharacters)istobereturned.

Example: lngLen=Len("VisualBasic")'lngLen=12

http://www.vb6.us/tutorials/vb6stringfunctions 1/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Function: Mid$(orMid)

Description: Returnsasubstringcontainingaspecifiednumberofcharactersfromastring.

Syntax: Mid$(string,start[,length])

TheMid$functionsyntaxhastheseparts:

stringRequired.Stringexpressionfromwhichcharactersarereturned.

startRequiredLong.Characterpositioninstringatwhichtheparttobetakenbegins.Ifstartis
greaterthanthenumberofcharactersinstring,Midreturnsazerolengthstring("").

lengthOptionalLong.Numberofcharacterstoreturn.Ifomittedoriftherearefewerthanlength
charactersinthetext(includingthecharacteratstart),allcharactersfromthestart
positiontotheendofthestringarereturned.

Example: strSubstr=Mid$("VisualBasic",3,4)'strSubstr="sual"

Note:Mid$canalsobeusedontheleftsideofanassignmentstatement,whereyoucanreplacea
substringwithinastring.

strTest="VisualBasic"
Mid$(strTest,3,4)="xxxx"

'strTestnowcontains"VixxxxBasic"

InVB6,theReplace$functionwasintroduced,whichcanalsobeusedtoreplacecharacterswithin
astring.

Function: Left$(orLeft)

http://www.vb6.us/tutorials/vb6stringfunctions 2/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Description: Returnsasubstringcontainingaspecifiednumberofcharactersfromthebeginning(leftside)ofa
string.

Syntax: Left$(string,length)

TheLeft$functionsyntaxhastheseparts:

stringRequired.Stringexpressionfromwhichtheleftmostcharactersarereturned.

lengthRequiredLong.Numericexpressionindicatinghowmanycharacterstoreturn.If0,azero
lengthstring("")isreturned.Ifgreaterthanorequaltothenumberofcharactersinstring,the
entirestringisreturned.

Example: strSubstr=Left$("VisualBasic",3)'strSubstr="Vis"

'NotethatthesamethingcouldbeaccomplishedwithMid$:
strSubstr=Mid$("VisualBasic",1,3)

Function: Right$(orRight)

Description: Returnsasubstringcontainingaspecifiednumberofcharactersfromtheend(rightside)ofa
string.

Syntax: Right$(string,length)

TheRight$functionsyntaxhastheseparts:

stringRequired.Stringexpressionfromwhichtherightmostcharactersarereturned.

lengthRequiredLong.Numericexpressionindicatinghowmanycharacterstoreturn.If0,azero
lengthstring("")isreturned.Ifgreaterthanorequaltothenumberofcharactersinstring,the
entirestringisreturned.

http://www.vb6.us/tutorials/vb6stringfunctions 3/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Example: strSubstr=Right$("VisualBasic",3)'strSubstr="sic"

'NotethatthesamethingcouldbeaccomplishedwithMid$:
strSubstr=Mid$("VisualBasic",10,3)

Function: UCase$(orUCase)

Description: Convertsalllowercaselettersinastringtouppercase.Anyexistinguppercaselettersandnonalpha
charactersremainunchanged.

Syntax: UCase$(string)

Example: strNew=UCase$("VisualBasic")'strNew="VISUALBASIC"

Function: LCase$(orLCase)

Description: Convertsalluppercaselettersinastringtolowercase.Anyexistinglowercaselettersandnonalpha
charactersremainunchanged.

Syntax: LCase$(string)

Example: strNew=LCase$("VisualBasic")'strNew="visualbasic"

Function: Instr

http://www.vb6.us/tutorials/vb6stringfunctions 4/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Description: ReturnsaLongspecifyingthepositionofonestringwithinanother.Thesearchstartseitheratthe
firstcharacterpositionoratthepositionspecifiedbythestartargument,andproceedsforward
towardtheendofthestring(stoppingwheneitherstring2isfoundorwhentheendofthestring1
isreached).

Syntax: InStr([start,]string1,string2[,compare])

TheInStrfunctionsyntaxhastheseparts:

startOptional.Numericexpressionthatsetsthestartingpositionforeachsearch.Ifomitted,
searchbeginsatthefirstcharacterposition.Thestartargumentisrequiredifcompareisspecified.

string1Required.Stringexpressionbeingsearched.

string2Required.Stringexpressionsought.

compareOptionalnumeric.Avalueof0(thedefault)specifiesabinary(casesensitive)search.A
valueof1specifiesatextual(caseinsensitive)search.

Examples: lngPos=Instr("VisualBasic","a")
'lngPos=5

lngPos=Instr(6,"VisualBasic","a")
'lngPos=9(startingatposition6)

lngPos=Instr("VisualBasic","A")
'lngPos=0(casesensitivesearch)

lngPos=Instr(1,"VisualBasic","A",1)
'lngPos=5(caseinsensitivesearch)

Function: InstrRev

http://www.vb6.us/tutorials/vb6stringfunctions 5/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Description: ReturnsaLongspecifyingthepositionofonestringwithinanother.Thesearchstartseitheratthe
lastcharacterpositionoratthepositionspecifiedbythestartargument,andproceedsbackward
towardthebeginningofthestring(stoppingwheneitherstring2isfoundorwhenthebeginningof
thestring1isreached).

IntroducedinVB6.

Syntax: InStrRev(string1,string2[,start,[,compare]])

TheInStrfunctionsyntaxhastheseparts:

string1Required.Stringexpressionbeingsearched.

string2Required.Stringexpressionsought.

startOptional.Numericexpressionthatsetsthestartingpositionforeachsearch.Ifomitted,

searchbeginsatthelastcharacterposition.

compareOptionalnumeric.Avalueof0(thedefault)specifiesabinary(casesensitive)search.A
valueof1specifiesatextual(caseinsensitive)search.

Examples: lngPos=InstrRev("VisualBasic","a")
'lngPos=9

lngPos=InstrRev("VisualBasic","a",6)
'lngPos=5(startingatposition6)

lngPos=InstrRev("VisualBasic","A")
'lngPos=0(casesensitivesearch)

lngPos=InstrRev("VisualBasic","A",,1)
'lngPos=9(caseinsensitivesearch)
'Notethatthislastexampleleavesaplaceholderforthestartargument

NotesonInstrandInstrRev:

http://www.vb6.us/tutorials/vb6stringfunctions 6/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

SomethingtowatchoutforisthatwhileInstrandInstrRevbothaccomplishthesamething(exceptthatInstrRev
processesastringfromlastcharactertofirst,whileInstrprocessesastringfromfirstcharactertolast),thearguments
tothesefunctionsarespecifiedinadifferentorder.TheInstrargumentsare(start,string1,string2,compare)whereas
theInstrRevargumentsare(string1,string2,start,compare).

TheInstrfunctionhasbeenaroundsincetheearlierdaysofBASIC,whereasInstrRevwasnotintroduceduntilVB6.

Builtin"vb"constantscanbeusedforthecompareargument:

vbBinaryComparefor0(casesensitivesearch)
vbTextComparefor1(caseinsensitivesearch)

Function: String$(orString)

Description: Returnsastringcontainingarepeatingcharacterstringofthelengthspecified.

Syntax: String$(number,character)

TheString$functionsyntaxhastheseparts:

numberRequiredLong.Lengthofthereturnedstring.

characterRequiredVariant.Thisargumentcaneitherbeanumberfrom0to255

(representingtheASCIIcharactercode*ofthecharactertoberepeated)orastring

expressionwhosefirstcharacterisusedtobuildthereturnstring.

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

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

*AlistoftheASCIIcharactercodesispresentedattheendofthistopic.

http://www.vb6.us/tutorials/vb6stringfunctions 7/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Function: Space$(orSpace)

Description: Returnsastringcontainingthespecifiednumberofblankspaces.

Syntax: Space$(number)

Wherenumberisthenumberofblankspacesdesired.

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

Function: Replace$(orReplace)

Description: Returnsastringinwhichaspecifiedsubstringhasbeenreplacedwithanothersubstringaspecified
numberoftimes.

IntroducedinVB6.

Syntax: Replace$(expression,find,replacewith[,start[,count[,compare]]])

TheReplace$functionsyntaxhastheseparts:

expressionRequired.Stringexpressioncontainingsubstringtoreplace.

findRequired.Substringbeingsearchedfor.

replacewithRequired.Replacementsubstring.

startOptional.Positionwithinexpressionwheresubstringsearchistobegin.Ifomitted,1is
assumed.

http://www.vb6.us/tutorials/vb6stringfunctions 8/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

countOptional.Numberofsubstringsubstitutionstoperform.Ifomitted,thedefaultvalueis
1,whichmeansmakeallpossiblesubstitutions.

compareOptional.Numericvalueindicatingthekindofcomparisontousewhenevaluating
substrings.(0=casesensitive,1=caseinsensitive)

Builtin"vb"constantscanbeusedforthecompareargument:

vbBinaryComparefor0(casesensitivesearch)
vbTextComparefor1(caseinsensitivesearch)

Examples: strNewDate=Replace$("08/31/2001","/","")
'strNewDate="08312001"

Function: StrReverse$(orStrReverse)

Description: Returnsastringinwhichthecharacterorderofaspecifiedstringisreversed.

IntroducedinVB6.

Syntax: StrReverse$(string)

Examples: strTest=StrReverse$("VisualBasic")'strTest="cisaBlausiV"

Function: LTrim$(orLTrim)

Description: Removesleadingblankspacesfromastring.

http://www.vb6.us/tutorials/vb6stringfunctions 9/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Syntax: LTrim$(string)

Examples: strTest=LTrim$("VisualBasic")
'strTest="VisualBasic"

Function: RTrim$(orRTrim)

Description: Removestrailingblankspacesfromastring.

Syntax: RTrim$(string)

Examples: strTest=RTrim$("VisualBasic")'strTest="VisualBasic"

Function: Trim$(orTrim)

Description: Removesbothleadingandtrailingblankspacesfromastring.

Syntax: Trim$(string)

Examples: strTest=Trim$("VisualBasic")'strTest="VisualBasic"
'Note:Trim$(x)accomplishesthesamethingasLTrim$(RTrim$(x))

Function: Asc

http://www.vb6.us/tutorials/vb6stringfunctions 10/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Description: ReturnsanIntegerrepresentingtheASCIIcharactercodecorrespondingtothefirstletterina
string.

Syntax: Asc(string)

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

Function: Chr$(orChr)

Description: Returnsastringcontainingthecharacterassociatedwiththespecifiedcharactercode.

Syntax: Chr$(charcode)

Wherecharcodeisanumberfrom0to255thatidentifiesthecharacter.

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

ASCIICharacterCodes(0through127)

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

http://www.vb6.us/tutorials/vb6stringfunctions 11/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

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 (linefeed) 42 * 74 J 106 j

11 N/A 43 + 75 K 107 k

12 N/A 44 , 76 L 108 l

13 (carriagereturn) 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

http://www.vb6.us/tutorials/vb6stringfunctions 12/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

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=Thesecharactersaren'tsupportedbyMicrosoftWindows.

ASCIICharacterCodes(128through255)

http://www.vb6.us/tutorials/vb6stringfunctions 13/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

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

http://www.vb6.us/tutorials/vb6stringfunctions 14/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

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

http://www.vb6.us/tutorials/vb6stringfunctions 15/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

158 N/A 190 222 254

159 N/A 191 223 255

N/A=Thesecharactersaren'tsupportedbyMicrosoftWindows.

ThevaluesinthetablearetheWindowsdefault.However,valuesintheANSIcharactersetabove127aredeterminedby
thecodepagespecifictoyouroperatingsystem.

"TryIt"Example

Todemonstratethebuiltinstringfunctions,setupa"TryIt"project,andplacethefollowingcodeinthecmdTryIt_Click
event:

PrivateSubcmdTryIt_Click()
DimstrTestAsString

strTest=InputBox("Pleaseenterastring:")

Print"UsingLen:";Tab(25);Len(strTest)
Print"UsingMid$:";Tab(25);Mid$(strTest,3,4)
Print"UsingLeft$:";Tab(25);Left$(strTest,3)
Print"UsingRight$:";Tab(25);Right$(strTest,2)
Print"UsingUCase$:";Tab(25);UCase$(strTest)
Print"UsingLCase$:";Tab(25);LCase$(strTest)
Print"UsingInstr:";Tab(25);InStr(strTest,"a")
Print"UsingInstrRev:";Tab(25);InStrRev(strTest,"a")
Print"UsingLTrim$:";Tab(25);LTrim$(strTest)
Print"UsingRTrim$:";Tab(25);RTrim$(strTest)
Print"UsingTrim$:";Tab(25);Trim$(strTest)
Print"UsingString$&Space$:";Tab(25);String$(3,"*")_
&Space$(2)_
&Trim$(strTest)_
&Space$(2)_
&String$(3,42)
Print"UsingReplace$:";Tab(25);Replace$(strTest,"a","*")
Print"UsingStrReverse$:";Tab(25);StrReverse$(strTest)
http://www.vb6.us/tutorials/vb6stringfunctions 16/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Print"UsingAsc:";Tab(25);Asc(strTest)
EndSub

Runtheprojectandclickthe"TryIt"button.Whentheinputboxcomesup,enterastringofyourchoice.

Sometipsonwhattoenter:

ToseetheeffectsofUCase$andLCase$,enteramixedcasestring.

TocompareInstrandInstrRev,enterastringwithatleasttwo"a"sinit.
ToseetheeffectsofLTrim$,RTrim$,andTrim$,enterastringwithleadingand/ortrailingspaces.

ToseetheeffectofReplace$,enterastringwithatleastone"a"init.

Youcanalsomodifythecodeandruntheprojecttoseeifyougettheresultsyouexpect.

ThescreenshotbelowshowsarunoftheprojectusingthecodeabovewherethestringVisualBasicwasinput:

DownloadtheVBprojectcodefortheexampleabovehere.

http://www.vb6.us/tutorials/vb6stringfunctions 17/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

VBAStringFunctions
AnimportantthingtonoteisthatallofthesefunctionsalsoworkwithVisualBasicforapplications.Whenworkingwiththe
VBAstringfunctionsyouwillcallthemintheexactsamewayasthesamplesdiscussedinthisarticle.Forexampleifyou
wanttofindthelengthofastringinVBAyouwouldusethis:Len("somestring").Ifyourunintoanyissuesdoingthis
pleasepostacommentbelow.

OriginallyWrittenByTheVBProgramer.Cleanedupandreformattedforthissite.

PosttoFacebook
PosttoTwitter

AddtoLinkedIn

Similarlinks
VB.NETInputBox

Button,Label,Textbox,CommonControls

UnderstandingCheckBoxes
UsingOptionButtonsakaRadioButtons
Understandingcontrolarrays

Understandingthetimercontrol
VB6ControlBasics

Kakodadodatemenijeuruntimeu
VisualBasicPowerPack

Browse,Open,andSaveDialogs

Ifyouenjoyedthispost,subscribeforupdates(it'sfree)
EmailAddress... Subscribe

StringManipulation Sun,01/12/201408:45ChaudhryWaqas(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 18/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Hieverybody...

IwanttomakeoneprogramwithFirst,SecondandLastnamefunction..

ForExample:
Iusethisname:Text1.text=ChaudhryWaqasVicky

andIneedthisnametobeshowas

YourFirstName=Chaudhry
YourSecondName=Waqas
YourLastName=Vicky

Pleaseifanyoneknowaboutthisplzletknow,,,

ch.vicky7779@gmail.com

AdvanceThankz.

hay Tue,02/05/201321:16frankyinnocent(notverified)

iftheinput23x1,216x11,1252x32thenIwantthesortedaccordingdigitbeforexthenthedataisenteredintothe
database.

Iwanttoeventuallylooklikethis

2digitsx3digitsx4digitx
23121611125232

pleasesendmeemailoryoucananswerithere.
thanksbefore.

http://www.vb6.us/tutorials/vb6stringfunctions 19/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

HowtouseVbpropercase? Wed,09/19/201223:09Christ(notverified)

UcaseandLcaseisworkingbutidontknowhowtousevbProperCasewhatisthecodeforthat?

Example:Itype"helloluna"itwillautomaticallygoeslikethis"HelloLuna"
afteryouclickspacebarorafteryoupress(.)itwillmakethefirstletterofthewordUppercase

Pleasehelpme...

ThispageisInteresting Wed,09/19/201222:57Christ(notverified)

wholikeprogramming?Iamnewinthispageandasireadallthecomments,questionsandanswersveryinteresting,What
canisayis"whosurfthispageisaluckyone"thankyousomuchithelpsmealot...

iwanttosearchstringin Sat,07/14/201219:54searchandcheckstring(notverified)

iwanttosearchstringinsentenceexample

name=lina
sentence=linawaseatingfriedchicken

iwanttosearchstringlinainsentences.howtodothatifihavemorethanonesentences

DimkAsStringk= Mon,12/03/201203:16Manobarathi(notverified)

DimkAsString
k="linawaseatingfriedchicken"
DimfAsString
http://www.vb6.us/tutorials/vb6stringfunctions 20/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

f="lina"
Dimf1AsString
f1=Left(k,4)
Console.WriteLine(f1)
Console.ReadKey()

STXandETXinvb6 Mon,06/25/201222:52Anonymous(notverified)

Hi,
Weareworkingwithvb6andneedtosendandatatoanintrumentthroughserialport
dataformatlookslikebelow
startoftext+data+endoftext[startoftext(02)andendoftext(03)areASCIIcodes]
whenweenterthekeyshortofstartoftext(Alt+2)andendoftext(Alt+3),itdisplaylike'?"andvb6showingerror
couldsomeonehelp,howtocanaddSTXandETXwhilesendingdatathroughserialport?
Deeplyappreciateallthereplies!
Thanks

UseChr()forASCIIControlCodes Wed,12/18/201313:32Loresayer(notverified)

STXandETXareASCIIcontrolcodes(theyareunprintableonscreen,andyourkeyboardhaskeysonitforsending
printablecharacters,andthesearen'tprintable,sotheoperatingsystemmapsthemto"?").

YoucanuseChr(2)forSTXandChr(3)forETX.

DimstrMsgAsString
strMsg=Chr(2)&"HelloWorld!"&Chr(3)

http://www.vb6.us/tutorials/vb6stringfunctions 21/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

VisualBasic Fri,05/18/201222:02SeyedIsmail(notverified)

DearAll,

IambeginnerinVB6,iammakingasmallsizedapplicationformycompany.forexample.MACAddresswhichiscomeas
00:00:00:00:00:00
,ifitypecharactersintotextboxlike000000000000,theoutputformatshouldbecomeasMACAddressformatabove
mentioned.

couldyoupleasehelpmeinthisregardandIlookforwardyourreply.

Regards,
SeyedIsmail

tryusingthis Tue,07/10/201200:47GeorgeL(notverified)

tryusingthisfunction:

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

trythisfunctionFORMAT(txt, Tue,07/10/201200:43GeorgeL(notverified)

trythisfunction
FORMAT(txt,"00:00:00:00:00:00")

MacThing Sun,05/27/201210:47AnonymousGuy(notverified)

Shouldn'tyoujustaddsomecodetellingtheprogramtoinsertacolonevery2digits
http://www.vb6.us/tutorials/vb6stringfunctions 22/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Withinaword Tue,05/15/201210:43AnonymousGuy(notverified)

Howdoyoufindasinglecharacterwithinaword.Forexample,findingtheletter"e"intheword"epicentre".

Howdoyoufindasingle Tue,05/15/201210:41Anonymous(notverified)

Howdoyoufindasinglecharaterinawordlikefindingan"e"intheword"cheese"?

Howtosavethenumber Mon,05/14/201222:14istyawan(notverified)

Ihaveatextfilethatcontaining
N10G00X20Z2
N20G01X18
N30G01X18Z10
Ialreadyopenthetextfilethroughlistbox.ButIneedtoextractthenumberfromthestring(N,G,X,Z)anstoredas
variable.Howtodoit?thankyou

imkindaconfusedinhowto Mon,04/23/201215:11woodlover123

imkindaconfusedinhowtoconvertwordsintoascii.youenterawordthanuclickconvertanditconvertsittoascii.for
example,woodw=119o=111o=111d=100.igottadothiswiththewholealphabet

http://www.vb6.us/tutorials/vb6stringfunctions 23/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Youhavetoloopcharbychar Wed,05/30/201215:15RobertRodriguez(notverified)

YouhavetoloopcharbychargettingtheindividualAsciivalueofthetextyouwanttoconvert,
forexampleinvb6:

DimsValueasString
dimsAsciiResultasstring

sValue="wood"

forx=0tolen(sValue)
sAsciiResult=Asc(mid(sValue,x,len(sValue)))
Debug.PrintsAsciiResult
loop

Note:Thisisanexamplewherethevbastringfunctionisthesameasthevb6one.

imkindaconfusedinhowto Mon,04/23/201215:08Anonymous(notverified)

imkindaconfusedinhowtoconvertwordsintoascii.youenterawordthanuclickconvertanditconvertsittoascii.for
example,woodw=119o=111o=111d=100.igottadothiswiththewholealphabet

howicanprintsecondpart Fri,03/23/201201:37rawan(notverified)

howicanprintsecondpartofnameincloudthreepartbymid,instr,left,rightfunction?

http://www.vb6.us/tutorials/vb6stringfunctions 24/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Toavoidduplicationofcharacter Thu,03/22/201223:39Lenard(notverified)

tnxmen....
it'shelpmetoavoidduplicationofcharacters
speciallyonamountsample:253.30.1itiswrong
itmustbe253.50only

here'smycodeIgotanideafromyourcode...

Dimx
PrivateSubtxt1_Change()
x=InStr(txt1,".")
EndSub
PrivateSubtxt1_KeyPress(KeyAsciiAsInteger)
IfKeyAscii=46Then
IfNotx=0Then
KeyAscii=0
EndIf
EndIf
EndSub

awesome Thu,02/23/201222:01rudreshgaur(notverified)

awesome

Hi,I'munabletofindthe Wed,01/18/201202:25sankark(notverified)

Hi,
I'munabletofindthedifferencebetweenfunctionswithandwithout$,somethinglikeStrng()andString$().plzgiverep
asap.

http://www.vb6.us/tutorials/vb6stringfunctions 25/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

programmingbookforbeginners Mon,01/02/201200:08PaulS.KAmegadze(notverified)

iwillbegratefulifsomeonecanhelpmeaccessaprogrammingbook.iamanoviceinthisfieldbuthavemuchinterestin
thesubjectrecently.countingonyou.

ProgrammingBook Wed,01/25/201221:46Anonymous(notverified)

Ingooglesearchfor"VisualBasicCourseNotesbyLouTylee".You'lleventuallyfindthebook.Thisbookissimply
awesome.

visualbasic Mon,03/12/201220:40jeanmae(notverified)

please.iameagertoknowprogrammingbutnomatterhowItryIreallycantunderstandanyofthecodes.

validation Wed,12/14/201113:33Anonymous(notverified)

hi,iwouldliketoknow,howdoyouvalidateapieceofstring:
letssaytheuserisrequiredtoenterastringof10letterswhicharebetweenaf.(egaaaaffbced)
Andtheprogramisrequiredtochecktoseeifeachletterthattheuserhastypediswithintheafrangesothatiftheinput
containsanoutofrangeletter(egaaagwsdfee)theprogramcanthendisplayanerrormessage(egmsgbox("pleaseenter
lettersthatareinafrange")
PLEASEHELPME.

http://www.vb6.us/tutorials/vb6stringfunctions 26/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

HI,PLSHELPME Tue,02/05/201300:23j.vimala(notverified)

,ihiwouldliketoknow,howdoyouvalidateapieceofstring:
letssaytheuserisrequiredtoenterastringof10letterswhichareACGT.(AAAAACCCGGGTTTTAGCTCCCGG)
Andtheprogramisrequiredtochecktoseeifeachletterthattheuserhastypediswithintheafrangesothatifthe
inputcontainsanoutofrangeletter(AAASGGTCC)theprogramcanthendisplayanerrormessage(egmsgbox("please
enterlettersthatareinafrange")

stringprograminVB Thu,12/01/201105:10Bujj(notverified)

hi...
programtofindsimilarcharactersinastringandpositionofthecharacters.Ex:Ifthestringis"Excellent"outputshouldbe
thereare3"e"andthepositionoftheeach"e"

Vb6StringOperation Fri,11/04/201111:14Anonymous(notverified)

Hithere,iwanttoremoveablankspacebetweenmorethanwordshowcaniachievethatinvb6
example:
word="VisualBasic"

iwantittobecome
word="VisualBasic"

outstandinginfoavailable Sat,10/22/201116:07MSarwer(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 27/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

thisisacomprehensiveknowledgeabtstringfunctionsyouhaveposted.

Requireatleastoneletterandnumberintextbox Tue,10/04/201115:26Anonymous(notverified)

TryingtodovalidationsforapasswordandtheonlypartIamstuckonischeckingthetextboxforbothalphaand
numbericcharacters.Theremustbeatleast1letterandatleast1number.Planningforthepossibilityofcomplex
passwords,Iwouldliketonotlimittoonlyalphanumericandalsoacceptspecialcharacters.Butfornowatleastjust
validatethatthetextboxisalphanumeric.Thanksinadvance.

TryThis Tue,11/01/201108:45Anonymous(notverified)

Text1.text="AbC1"

PrivateSubCommand1_Click()
Forx=1ToLen(Text1.Text)
IfAsc(Mid(Text1.Text,x,1))>47AndAsc(Mid(Text1.Text,x,1))<58Then
iNumber=True
ExitFor
EndIf
Nextx

Forx=1ToLen(Text1.Text)
IfAsc(Mid(Text1.Text,x,1))>96AndAsc(Mid(Text1.Text,x,1))<123Then
iLowerCase=True
ExitFor
EndIf
Nextx

Forx=1ToLen(Text1.Text)
IfAsc(Mid(Text1.Text,x,1))>64AndAsc(Mid(Text1.Text,x,1))<91Then
iUpperCase=True

http://www.vb6.us/tutorials/vb6stringfunctions 28/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

ExitFor
EndIf
Nextx

If(iNumberAndiLowerCase)Or(iNumberAndiUpperCase)Then
MsgBox("GoodPassword")
Else
MsgBox("BadPassword")
EndIf
EndSub

AlloftheseworkasVBAstringfunctionsaswell.

StringtoArrayofCharacter Mon,09/19/201123:29Gumz(notverified)

Howtoconvertstringtoarrayofcharacters?

stringcount Sun,09/11/201121:24ysasaginiling

cansomebodyhelpmewithmyproject?ineedtocreateasimplesystemthatcancountanythingthathasbeentypedon
textbox

example:

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

theinputshouldbelimitedto60charactersonly,elseitwilldisplay"morethan60characters"

thanks!:)

http://www.vb6.us/tutorials/vb6stringfunctions 29/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Hopeyougotthis Tue,01/03/201205:57Prabakar(notverified)

PrivateSubText1_Change()
If(Len(Text1.Text)>=60)Then
MsgBox"60Charactersonlyaccepted",vbCritical,Error
Text2.text=len(Text1.text)
EndIf
EndSub

VB6.0 Tue,08/16/201106:58rakshitha(notverified)

Ishouldnotbeabletoenteranyotherchaaractersotherthennumbersinthetextbox.AmworkingonVB6..plsgiveme
thesuggestion..

PrivateSub Wed,10/05/201100:47akhil3469(notverified)

PrivateSubtext1_KeyPress(KeyAsciiAsInteger)
IfKeyAscii<48OrKeyAscii>57ThenKeyAscii=0
EndSub

hopeitwillhelpu..

Onlyacceptnumericdatafortextboxcontrol Wed,09/07/201122:48fievb_mentor(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 30/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

AddcontroltextboxnameText1toyourform
doubleclickonthatcontrol,changetheeventtoKeyPress.Copyandpastethecodebellow.
Perhapsthecodehelpforyou...

PrivateSubText1_KeyPress(KeyAsciiAsInteger)
SelectCaseKeyAscii
CaseAsc("0")ToAsc("9"),1To31:KeyAscii=KeyAscii
CaseAsc("."),Asc(","):KeyAscii=KeyAscii'Incaseyouaresupposetouseformatingnumerice.g.1,234,567.89
CaseElse
KeyAscii=0
EndSelect
EndSub

storingeachcharacterfromatextboxinanarray Tue,08/09/201100:25vikramurdu(notverified)

Fori=0To9Step1
password(i)=Text1.Text
Next
Fori=0To9Step1
text2.text=text2.text+password(i)
Next

hereisthecaseiwanteachcharacterenteredinthetextboxinanarray........

StringtoArray Thu,09/01/201122:48deadmonk(notverified)

dimpassword()asbyte
password=Text1.text

DimiAsLong
Text2.Text=vbNullstring

http://www.vb6.us/tutorials/vb6stringfunctions 31/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Fori=0ToUBound(password)
Text2.Text=Text2.Text&Chr(password(i))
Nexti

Languagetranslationproblem Sat,08/06/201104:09NileshLondhe(notverified)

Hi....
IhaveaAccessDatabasewithEmp_Name_EngfieldsettotextshowsthenameofemployeeinEnglishLanguage.
IwanttoaddnewfieldEmp_Name_MarathiwhichconvertEnglishnametoMarathiLanguage.
Ifanyonehavecodeforthatpleasesendme.

OrsendmethecodeforConversionofEnglishcharacterstostandardUnicode.

PleaseHelpMe.

Languagetranslationproblem Sat,08/06/201104:08NileshLondhe(notverified)

Hi....
IhaveaAccessDatabasewithEmp_Name_EngfieldsettotextshowsthenameofemployeeinEnglishLanguage.
IwanttoaddnewfieldEmp_Name_MarathiwhichconvertEnglishnametoMarathiLanguage.
Ifanyonehavecodeforthatpleasesendme.

OrsendmethecodeforConversionofEnglishcharacterstostandardUnicode.

PleaseHelpMe.

ThankYou! Mon,07/18/201110:51Anonymous(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 32/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

IamdoingparttimeBCA.Mycollegenotessuckbigtime.Theydon'tevencontainhalfofthepopularandbasicfunctions.
HaditnotbeenforthistutorialonVB6,Iwouldn'thavemanagedtoevengetthebasicideaaboutusingVB6.
Thanks!You'vebeenveryhelpful.:)

HELPPPPPPPPPPP Mon,07/18/201110:12Thenet(notverified)

Ihaveasulutionis:
Iwantconvertstringtomorestringbyspcialword
Ex1:Inputstringtotextboxis"TestTest|"outputisTestTest.Butwhenisnotspical"|"thenoutputis"TestorTest"
Ex2:Inputistype"Tes?t"thenoutputisreplaceword"?"byoneornothingword.
Ex3:Inputistype"Te_t"thenoutputisreplaceword"_"byjustoneeveryword.

SorrylanguageEnglishisnotwell.
Thankyouverymuch

Replace Wed,09/07/201122:28fievb_mentor(notverified)

Iknowwhatyoumeant,itsverysimple...

Ex1:Inputstringtotextboxis"TestTest|"outputisTestTest.Butwhenisnotspical"|"thenoutputis"TestorTest"
Answer:
Exp1=Replace("TestTest|","|","")

Ex2:Inputistype"Tes?t"thenoutputisreplaceword"?"byoneornothingword.
Answer:
Exp2=Replace("Tes?t","?","",1,1)

Ex3:Inputistype"Te_t"thenoutputisreplaceword"_"byjustoneeveryword.
Answer:
Exp2=Replace("Te_t","_","",1,1)

http://www.vb6.us/tutorials/vb6stringfunctions 33/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

MayAllahrewardthevbinfo Wed,07/06/201104:26Fairoz(notverified)

MayAllahrewardthevbinfoproviderwithall.IamhighlyhappythatIhavegainedalot.Iwishsointhefuture.

datagrid Tue,07/05/201101:12ankitamanjrekar

howtovalidatedataenteredinfieldsofdatagrid

Pleasealittlehelp Sun,06/12/201112:19Topo_AS(notverified)

Iusethiscode:

SubTransformare()
Fori=1ToLen(timp)
IfMid(timp,i,1)="."Thenunu=i:ExitFor
Nexti
timp2=Mid(timp,unu+1,Len(timp)unu)
Fori=1ToLen(timp2)
IfMid(timp2,i,1)="."Thendoi=i:ExitFor
Nexti
doi=doi+unu
IfLen(timp)doi>3ThenMsgBox"Timpintrodusgresit!"&vbCrLf&"Verificatitimpii!"
zecimi=Val(Mid(timp,1,unu1)*6000)+Val(Mid(timp,unu+1,doi1unu)*100)+Val(Mid(timp,doi+1,
Len(timp)doi))
EndSub
theinitialvaluesarefrommshflexgridandaresomethinglikethis:2.35.58timeandthecodeiscovertingtomiliseconds.
whatitrytodoisifoneormoreoftheinitialvaluesare"ABANDON"thenthecodetoskipthatrow.cansomeonehelpme?

http://www.vb6.us/tutorials/vb6stringfunctions 34/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Helpplease! Thu,05/12/201115:28Veronika(notverified)

Hitoall
Pleasehelpme.IneedurgentcodeforcomparewordsintwolistsinExcelandwhenonewordisrepeateinbothliststhen
thiswordhavetobecoloured.
Thanksinadvancetoall

HELPPPPPPPPPPPASAPPPPPPPPPPPPPPP! Tue,03/29/201101:50Anonymous(notverified)

HI!IWANTTOCOMPAREMYTXBX1TOMYTXBX2.IFTHECHARACTERS(EVENRANDOMIZE)INTXBX1ISDIFFERENTTO
TXBX2THENTHEANSWERINTXBX3ISNOIFELSEYES.WHATARETHECODES?ASAP!HELPPLS!

veryeasy.sortout Fri,01/20/201214:42Anonymous(notverified)

veryeasy.

sortoutalphabeticallyeachentry,thencomparethemtoeachothers.

comparevalueintextboxes Sat,04/02/201100:46sanjana(notverified)

quickanswercozidonthavetimeforimplementation

Assumeyouthatyouhavethreetextboxes:

http://www.vb6.us/tutorials/vb6stringfunctions 35/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

iftxtbox1.text=txtbox2.textthen
textbox1.text=yes
else
textbox1.text=no
endif

trythat

comparingtextboxes Tue,09/13/201107:49iantitus(notverified)

iftextbox1.text=text2box.textthen
textbox3.text="yes"
else
textbox3.text="no"
endif

reply Wed,05/25/201119:34Anonymous(notverified)

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

programthatonlydisplaysthosestringsbeginswithletter"b" Wed,03/16/201103:22laura(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 36/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

howtodoaprogramthatreadsaseriesofstringsfromtheuseranddisplaysonlythosestringsbeginningwiththeletter
"b"

plswritetomestatements Mon,02/14/201123:22Anonymous(notverified)

plswritetomestatementsinBASIC
(1)toreplacetworightcharactersofthestringA$by"IN"

IwanttofindtheNumberinStringinVBAmacros Mon,01/31/201122:33NIcky(notverified)

HiCananyonehelpmetofindthenumberinAlphanumricstringinVBAeg.ifihav12abcthentheoutputwillbe12

VAL() Thu,05/05/201118:08Anonymous(notverified)

VAL()

findstringthatendswithaunderscore Sun,01/09/201103:03Anonymous(notverified)

searchingdownalistboxforstringsthatendwithanunderscore_..notsurehowtogetittoworkcorrectly,cananyone
helpplease?

http://www.vb6.us/tutorials/vb6stringfunctions 37/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

hopethishelps. Tue,05/24/201123:43Stop(notverified)

'needed:
'text1.text="text_"
'text2.text=""
'commandbutton
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PrivateSubCommand1_Click()
IfRight(Text1.Text,1)="_"Then
Text2.Text="true"
Else:Text2.Text="False"
EndIf
EndSub
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'hopethishelps
Stop

convogame Fri,01/07/201115:34johnnadeau(notverified)

iwanttodoaconversationwithuseofalableandaniputbox
thelablecaptionsays"howareyou?"
thentheuseranswerswritingintheinputbox..
iwanttobeabletodeterminewhathewritessortoflikethis
ifinputbox.text=good,or,fine,or,happy,or...likeusingabuchofexamplessoasnottohavetowrite
atonofifthenstatementsforeachquestionthatIasktheuser.

Solution Mon,02/14/201101:09v4r14bl3(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 38/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Youcoulddeclarethepositiveexpressionsandthenegativeexpressionsonceandthencallitoverandoveragain.You
couldalsodividethemintootherclasses.
Forexample:


Usethisinamodule:

PublicFunctionGetPositiveInput(whatAsInteger)AsString

SelectCasewhat
Case1
GetPositiveInput="good"
Case2
GetPositiveInput="great"
Case3
GetPositiveInput="fine"
EndSelect
EndFunction


Tocallthis,youcoulduse:

PrivateSubForm_Load()
DimxAsString,yAsInteger,zAsString

x=InputBox("Howareyou?","Question")
Fory=1To3
z=GetPositiveInput(y)
Ifx=zThen
MsgBox"lol..Goodday.."
ExitSub
EndIf
Nexty
EndSub

Ifyouneedanymorehelpcontactmehere:sakhawat21@gmail.com

http://www.vb6.us/tutorials/vb6stringfunctions 39/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Linkingrecordcells Mon,11/01/201006:26heeeeeellllllpppppppppppppp!!!!(notverified)

Pleasebearwithmeifthisisabitsketchy.
IhaveaphpformthatfeedsbacktoaMySQLdatabase.ThisisthenaccessedwithanAccessdb.
OnthephpformIhaveadropdownboxthathasalistofusers.Whenauserselectsoneoftheseusersitautofillsalinked
cellontheformwiththeusersFirstinitialandSurname.
ThedataissentalongwithotherselectionsfromtheformtoasinglerecordintheMySQLdb.Ithencopythetablethat
thisdataisheldinsoIhaveabackupoftheoriginalrecordsandaworkingcopytomakechangesto.

Myproblemishere.IfusingtheAccessdbtoamendtherecordsandadifferentuserisselcetedfromthedropdownmenu
thelinkedcellintherecorddoesnotupdate.ThetablethatpopulatesthedropdowniscalledExec_listandhasheadings
Autonumber,Exec_name,email,Tel,Initialed_name.

WhatIneedistobeabletolinkthedropdownlisttotheInitialed_namesothatifanyoneselectsanotheruseritupdates
theInitlialed_namesection.

IfyourequireanythingelsepleasecontactmeandIwillseewhatIcando.Thissectionaffectsabout34otheroperations
inmyapplicationsoIneedhelp.

Hopeyoucanhelpinsomeway.

Dan

Thanksalot Wed,10/20/201012:42Maddy(notverified)

Thanksalotforconsolidatingthestringfunctions.Thishelpedmeinbuildingamacrotogeneraterandompassword.

http://www.vb6.us/tutorials/vb6stringfunctions 40/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Plshelp Thu,09/30/201006:05Anonymous(notverified)

Ineedtocreateanapplicationinvb6tostoremycdkeysofvarioussoftwares.Inthetextbox,ineedtoautomaticallyadd
anhyphen()afterevery5charactersasinusualcdkeys.Howdoidoitnstoreitinadatabase.Plshelp...

StringSearch&Replacementwithanothercharacter Thu,09/23/201006:32sakthi(notverified)

Howtosearchforacharacterinstringinreverseorderandreplaceitwithanothercharacter?

plshelpme Fri,09/03/201013:04pintu(notverified)

ifweenterthewordESTABLISHMENT,firstwecheckthelastcharacterTinthedatabasetableifwegetitthenitwill
count1character,ifitwillnotfoundinthedatabasethenleaveit,thencheckthelast2characterNTinthedatabaseif
foundthencount2character,likethiscountthewholewordandcheckitindatabasetable,nowwehavethecounts1
character,2character,...sothenreplace/deletethelargestcountofcharacterbytheparticularcharacterwhichispresent
inthedatabase.....
thanku

Sendingastringthroughmscomm Mon,08/23/201006:20applied(notverified)

Hello,
Iwouldliketoknowhowicansendastringlike4352119outoftheserialportatabaudrateofsay9600.Howisitgoing
tobesent?Aretheygoingtobesentoutindividually,like4willbesentoutfollowedby3andsoon,withastartandstop
bitforeachone?I'musingVB6
MSComm1.Output="4352119"

http://www.vb6.us/tutorials/vb6stringfunctions 41/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Findstring Wed,08/18/201006:57Anonymous(notverified)

VerynewtoVB.Needcodetocopythestringthatfollows"PMTINFO:TRN*1*"tothenext*toacellrightbesidethisdata
fieldinexcel.Sowouldneed123456789intheexamplebelow.Thenumberofcharacterstoreturnwillvaryandinsome
caseswillnotbepresentatall.Thenumberofrowstosearchwillalsovary.Pleasehelp...

PayorNameDES:CUSTEFTSID:XXXXX2061INDN:PracticeNameCOID:1066033492CCDPMT
INFO:TRN*1*123456789*55555555544345034112/30UNPOSTEDNOREASON.CN

Solution,Didnottest,buttheideaiscorrect Wed,09/22/201014:47Anonymous(notverified)

DimNumberAsString
DimStartAsInteger
DimEndAsInteger

'Selectthecellthathasthe"PMTINFO:TRN*1*"tag,
objSpread.Application.Cells.Find(What:="PMTINFO:TRN*1*",LookIn:=xlFormulas,_
LookAt:=xlPart,SearchOrder:=xlByRows,SearchDirection:=xlNext,_
MatchCase:=True,SearchFormat:=False).Activate

'Theactualvalueisonthiscell,butsomeformattingisrequiredtostripthenumber
Start=InStr(objSpread.Application.Selection.Value,"PMTINFO:TRN*1*")+15
End=InStr(Start,objSpread.Application.Selection.Value,"*")
Number=Mid$(objSpread.Application.Selection.Value,Start+1,EndStart)

Debug.PrintNumber

helppls Tue,08/17/201016:23Anonymous(notverified)

intextboxiusethiscode
PrivateSubText1_Change()

http://www.vb6.us/tutorials/vb6stringfunctions 42/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

'Allowonlynumbers."
EndSub
PrivateSubText1_KeyPress(KeyAsciiAsInteger)
DimchAsString
ch=Chr$(KeyAscii)
IfNot(ch>="1"Andch<="4")Then
'Cancelthecharacter.
KeyAscii=0
EndIf
EndSub
buticandusedeleteorbackspace....
plshelpmeineedtousethedeleteorbackspace.?????thanks

Here'sthesolution Mon,02/14/201100:40v4r14bl3(notverified)

PrivateSubText1_KeyPress(KeyAsciiAsInteger)
IfKeyAscii>Asc("9")OrKeyAscii<Asc("0")AndKeyAscii<>vbKeyBackThen
KeyAscii=0
EndIf
EndSub

Itworks100%

Keytrapping Sun,01/23/201103:06helper(notverified)

trythefolowing

'declarethisasconstatdeclarationsinform
ConstvbKeyDecPt=46

http://www.vb6.us/tutorials/vb6stringfunctions 43/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Onlyallownumberkeys,decimalpoint,orbackspace
If(KeyAscii>=vbKey0AndKeyAscii<=vbKey9)OrKeyAscii=vbKeyDecPtOrKeyAscii=vbKeyBackThen
ExitSub
Else
KeyAscii=0
Beep
EndIf
EndSub

itseasyitwillworkforsure

disismyreply Tue,11/02/201003:31MaryAnnIgnaco(notverified)

PrivateSubText1_KeyPress(KeyAsciiAsInteger)
IfKeyAscii<48OrKeyAscii>57Then
KeyAscii=0
EndIf

specialkeysaccessorcatchfromtheKeydownevent Sat,09/11/201012:08Anonymous(notverified)
oftextbox
YouwillusetheKeyDowneventtoaccessthebackspaceanddeleteorotherspecialkeys,....:)

trythisPrivateSub Thu,09/09/201007:12ryangilfoz(notverified)

trythis

http://www.vb6.us/tutorials/vb6stringfunctions 44/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

PrivateSubText1_Change()
IfIsNumeric(Text1.Text)=FalseThen
Text1.Text=""
EndIf
EndSub

helppls Tue,08/17/201015:52jo(notverified)

intextboxiusethiscode
PrivateSubText1_Change()
'Allowonlynumbers."
EndSub
PrivateSubText1_KeyPress(KeyAsciiAsInteger)
DimchAsString
ch=Chr$(KeyAscii)
IfNot(ch>="1"Andch<="4")Then
'Cancelthecharacter.
KeyAscii=0
EndIf
EndSub
buticandusedeleteorbackspace....
plshelpmeineedtousethedeleteorbackspace.?????thanks

PrivateSub Wed,09/01/201005:23Anonymous(notverified)

PrivateSubText1_KeyPress(KeyAsciiAsInteger)
DimchAsString
ch=Chr$(KeyAscii)
IfNot(ch>="1"Andch<="4")Then
'Cancelthecharacter.

http://www.vb6.us/tutorials/vb6stringfunctions 45/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

IfKeyAscii>=32Then'checksforcontrolkeys
KeyAscii=0
EndIf

EndIf
EndSub

Hopethishelps:)

Hello...Anybodytheretohelpmeplease Wed,08/04/201021:05Anonymous(notverified)

Iwouldliketocopyfromaaccesstabletoanothertable(twotextvalue)

vertdb.Execute"insertintoosdbox(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&"')"

theproblemisbeforescrip(testvalue)'iscomming.

pleasegivemethecorrectcommandtoremove'symbolfromscrip

easytousethesqlcommand:)[Vinay] Sat,09/11/201012:15Anonymous(notverified)

vertdb.Execute"insertintoosdboxvalues(select*fromothertable)"

keepinmindthebothtablesfieldsstructuresaresamethentheabovecommandwillwork,behappy...
feelfreetoaskanotherquestiononmyemailguptavinay.1@gmail.com

http://www.vb6.us/tutorials/vb6stringfunctions 46/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

2knowaboutstringfunctions Thu,07/22/201010:29Anonymous(notverified)

iwant2knowabriefdescriptionaboutstringfunctions....................................

Nope.avi Thu,04/07/201110:30Anonymous(notverified)

Sorry,can'tdothat.First,youmusttaketheepicjourneyoflearningtospell

Howtoavoid"&"charactertointerruptstring. Thu,07/15/201006:54Alessandro(notverified)

IhaveaVBAcodewhichallowsmetopickfieldsfromaDBandsendemail.
Itsoundslike:Me.Email.HyperlinkAddress="mailto:"&RecipientName&"<"&RecipientAddress&">"
TheproblemisthatiftheRecipientNamefieldhasthe"&"characterinit,thestringistruncatedatthatpoint.
IhavetriedtouseReplaceandFormatfunctionswithChr(38)code,butwithoutsuccess.
HowcanIdo?Thankyou.

Test Sat,07/10/201000:46Subin(notverified)

SubCheckTCNumber()
DimCountAsInteger
DimNumAsInteger
DimLastRowAsInteger
DimTCStringAsString
DimTCScenarioAsString
LastRow=ActiveSheet.UsedRange.Rows.Count
Num=1

http://www.vb6.us/tutorials/vb6stringfunctions 47/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Count=1
ForrwNumber=3ToLastRow

IfActiveSheet.Cells(rwNumber,1).Value<>""Then
IfCount<10Then
TCString="TC00"+Trim(Str$(Count))
Else
TCString="TC0"+Trim(Str$(Count))
EndIf

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
EndIf
NextrwNumber
MsgBox"Testcasenumberchecked"

EndSub

HelpMePlease Sun,07/04/201013:13itangel(notverified)

DearFriends

Imnewinvb2005.iwantthat

1.ihavetoenterasentencetoatextfieldandwhenipressabuttonthenmygivensentencewillsplitintowordsand
replacethesewordsfrommysqldatabase

example:ihaveentered"iamfineandok"

then"i"willbeconvertedto"eye"

"am"to"m"

http://www.vb6.us/tutorials/vb6stringfunctions 48/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

"fine"to"f9"

"and"to"n"

"ok"to"okay"

andthisshowsentenceagain"eyemf9nokay"ontextfield

butthesewordsandreplacingwordswillbetakenfrommysqldatabase

Pleasehelpmesir.......

regards::::iteagle

VB Thu,10/10/201322:51skkarthik(notverified)

DimaAsString
DimbAsString
DimcAsString
DimresultAsString

result=txt_1.Text
MsgBoxReplace(a,b,c)

Example:
a="WelcomeToVisualBasic"
b="To"
c="2"

Ans=Welcome2Visualbasic

Design:
text1=a
text2=b
text3=c

http://www.vb6.us/tutorials/vb6stringfunctions 49/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

ifyourdatabaseincludes Wed,07/14/201005:08Anonymous(notverified)

ifyourdatabaseincludes"firstword"and"secondword"..forexample"I"and"eye"..
thenyouhavetowritedownthewholedatabaseintoanarray..likefirstword()andsecondword()

soyoucanjustsay:"

fori=0tocount(firstword)

strString=replace(strString,firstword(i),secondword(i))

next
"

theresultwillbe:"eyemf9nokay"!

Veryusefulsite Sat,07/03/201001:23S.S.Sahoo(notverified)

Hi......All
ThaiisS.S.Sahoo.iamworkingasasoftwareengg.
todayivoughtthissitethroughgoogle.
&Ifoundthatthisisabestsiteforthosewhowanttolearnsomething.
Andalsoilearntalotfromthissite........iwilldefinitelyusethissiteforlearnmore.&suggestyoupeopletogothroughthis
site&spendsometime,ifurserious.
Thanks
Jipu

http://www.vb6.us/tutorials/vb6stringfunctions 50/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

hiiwanttosearchaname Mon,06/28/201004:52Anonymous(notverified)

hiiwanttosearchanamewhichisoflengtharoung40characterfromasqldatabaseusingtherecordset.
plzhelpme
ijustneededitformyproject

Thanksalotforthis Tue,06/22/201023:59KarthikBoddu(notverified)

ThanksalotforthisinformationonVBstringfunctions.

HELPPPPP Wed,06/02/201008:03abeera(notverified)

gr8tutorialbutineedsomehelp...iwanttomanipulateeachcharacterseparatlyenteredinthetextbox....actuallyiwantto
riteaceasercipheralgoinVBnsoforthatihavetoconsidereachcharacterseparately...kindlyhelpmeoutonhowtodo
it....thx

Helpwithsearchingstringfunctions Wed,10/27/201002:12Joe(notverified)

Thissitehasshownmelotsofshortcutstostringprocessingprocedures,butbeforethatIusedtousethefollowing
techniqueforprocessinganystringortext:
'let'ssaythetextiscalledjoetext
joetext="Howdybuddies?"
'thelengthofthestringisjoelen
joelen=Len(joetext)
'andthencomesaddressingeachcharacterseparately
ForI=1tojoelen

http://www.vb6.us/tutorials/vb6stringfunctions 51/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

currentchar=Left$(Mid$(joetext,I),1)
NextI
'nowforeachroundoftheloopthecharacterwouldbestoredincurrentchar.

Thatwayyoucandowhateveryouwantwitheachcharacterinsidetheloopmentionedabove!

Doyourownworkyoudork! Thu,06/17/201008:52Anonymous(notverified)

You'reassignedhomeworkforapurpose.Spendthetimetolearnhowtodoyourassignmentyourself.

Although...Ifyoucan'tevenspell"write"correctlyyou'reprobablyscrewedanyways.

comments Tue,03/23/201020:44biplabkumarshome(notverified)

wow!thispagehasbeenreallyusefulforme.inthissinglepageigotallthenoteswhichirequiredaboutstringfunctions.
thanksalottothewriter.

HiAll,Ihavean Sat,03/20/201021:25Anonymous(notverified)

HiAll,

IhaveanassignmentwhereIhavetovalidateapasswordusingtheIsValalidfunctionwhichshouldacceptastringasits
argumentandreturnaBooleanvalue.Thepasswordmustbeatleast6characterslongandhaveatleastonenumericdigit
andatleastonealphbeticcharacter.Ifthepasswordisvalid,thefunctionshouldreturnTrue.Otherwise,itshouldreturn
false.Anyhelpwouldbegreatyappreciated.RightnowIhavethedesignsetforinputtobeinaninputboxbutamlosthow
toaccomplishallthesevalidations.Thanksinadvance!

http://www.vb6.us/tutorials/vb6stringfunctions 52/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

greatpost,superblog.Made Mon,03/01/201012:17sazeni(notverified)

greatpost,superblog.Madeexercises.Helpalot.Thanks

hiihaveaproblemin Wed,02/17/201004:01Anonymous(notverified)

hiihaveaproblemingettingtheacronyminvisualbasicusingthestring....

Additionalexerciseschapter4pg89oftheworkbook Tue,02/09/201009:13Anonymous(notverified)

hi,

icantfigureoutthecodetoreadinreverse.iwouldreallylikesomehelpwithit.

thankyou.

VB6 Fri,02/26/201003:40Anonymous(notverified)

whatcodethatallowtheusertosearchthedetailsabouttheword..forexample,iwanttosearchthenameofsinger
specificallyRegineVelasquez....thenitwilldisplayheralbumsandwhenitwaspublish..theoutputcomesoutin
listbox...thxforurhelpahead...

http://www.vb6.us/tutorials/vb6stringfunctions 53/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

simplyunderstandable!!!! Fri,02/05/201007:13maya(notverified)

Thispageisreallyniceandhelpedmealottoknowtheuseofcodeandhowtousethosecodeinourprogram.Thanksfor
doingthisexcellentjob.

MSAccessformfilter Fri,01/29/201012:21Anonymous(notverified)

HowcanIlimitrecordsusedinaformtofieldstartingwith"S"?

hey Thu,01/21/201006:34ninjo(notverified)

howtosearcharecordeveniftherecordthatyouarefindingisinpropercaseandyoutypeinthesearchtxtboxaloweror
uppercasesentries?

writingfrequencycodes Wed,01/13/201006:02Anonymous(notverified)

cansomeonehelwithfrequencycodeforVBProgram,urgentpls

help Wed,01/13/201005:55Anonymous(notverified)

canuhelpmewiththefrequencycodesinVb

http://www.vb6.us/tutorials/vb6stringfunctions 54/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

hiall,imanew Fri,01/08/201005:56Anonymous(notverified)

hiall,
imanewinvb6andimworkingwithaprogramthatusesdatabasecouldsomeonehelpmeonhowtolinkthedatabase
access
incorrespondingtextboxsameaswhenimaddingdatainvb6guiitwillsaveonmydatabaseusingacommand?any
responce
wasgreatfullyappriciated..

response Tue,01/19/201018:50boggs(notverified)

trythesesites.
www.vbexplorer.com
www.vbtutor.net
Thereareseveralwaystoconnectyourformtoadatabase..
through:
DAO"themostbasic"
ADODC

Wouldyouliketohelpme. Fri,01/08/201001:11Pamuji(notverified)

Wouldyouliketohelpme.howtomakemirrortextinvb6..thank'sbefore..

Iminthemiddleofmaking Wed,12/30/200908:48Anonymous(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 55/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Iminthemiddleofmakingmyprogram,Itiswhereucountthenumberofcharactersina2certaintextboxliketheLen
functionandthenuaddtheirsumwhichwillshowinanothertextbox.Whatcodeshouldiuseinthecommandbutton?
HELPASAP!TNX,

EXCELLENT Wed,12/30/200904:45Anonymous(notverified)

EXCELLENT

needhelpparsingstrings Sun,12/27/200903:54dee(notverified)

helloall,
pleaseshowmehowtodisplaythecommaseparatedstring:"abc,345101,tr987".
inmyprogram,imenteringthevalueintoatextbox,usingthesplit()functionimsplittingbasedon","

code:
DimvaluesAsString
values=TextBox1.Text
DimstrAsString()=Nothing
str=values.Split(",")

Myproblemisidunnohowtoshowtheseparatedpartsofthestringinto3differenttextboxes...TextBox2andTextBox3
andTextTextBox4.
Thankyou!

Howtousesplit Sat,01/16/201013:21FaTe(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 56/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

DimValuesAsString'Valuesisastringinput
Values=TextBox1.Text

DimstrasVariant'strhoweverisanArray()sowedeclareitasVariant
str=Split(Values,",")'SplitValuesbythecomervalue,

Text1=str(0)'Nowwecanassignthetextboxesvalues.
Text2=str(1)'RememberanArray()alwaysstartsfrom0
Text3=str(2)
Text4=str(3)

Enjoy

Thankyou! Thu,12/17/200906:27Irsan(notverified)

Wow,itaccelaratesmyVBAskillstremendeously!Thanksfortheefforts!

Howtoreadthefilenamefromthepathname Sun,11/08/200911:03Trying2(notverified)

Hi,

Iwantedtoreadthefilenamefromapathname.For,example:

Pathname:"C:\Users\Admin\Desktop\Wrk\VirtualGraphs\VBWork\WorkfromSep09\Projection.img"

Ineedtogetthefilename"Projection"

Pleasehelp.

http://www.vb6.us/tutorials/vb6stringfunctions 57/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Howtousesplit Sat,01/16/201017:58FaTeY(notverified)

Again,,,

DimPathNameasstring'Defineyouroriginalpathasastring
DimPathBrokenasVariant'Arrayforbrakingyourpathintopieces
DimFileNameasVariant'Theendresultfilenameyousodesire:P

PathName="C:\Users\Admin\Desktop\Wrk\VirtualGraphs\VBWork\WorkfromSep09\Projection.img"

PathBroken=Split(pathName,"\")'SplitthePathby\

'NowwewantthelastpieceofthedatainPathBrokenso
'weuseUbound()whichtellsustheamountofpiecesinthesplitarray
'SowegetPathBroken(thelastpiece)
'forfurthernoteLbound()returnsthefirstpiece

FileName=PathBroken(Ubound(PathBroken))

:)

Howtoreadthefilenamefromthepathname Mon,11/09/200903:42AkhlD(notverified)

wegatthepathasPathname:"C:\Users\Admin\Desktop\Wrk\VirtualGraphs\VBWork\WorkfromSep
09\Projection.img"

sousetheInstrRevwithyerpath.ie,

Strlen=Len(pathname)
Intpos=InstrRev(pathname,"\")
Intlens=lenIntpos
filename=Mid(pathname,Intpos,Intlens)
MsgBox"Hurraaaayywegatthefilename:"&filename

nowfilename="\Projection.img"enjoy!

http://www.vb6.us/tutorials/vb6stringfunctions 58/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Unicode Sat,10/24/200907:39Anonymous(notverified)

Cananybodyhelp?IwanttomakeUnicodecharacter(likeChr(Number)butinunicode).

helpme Wed,10/14/200906:51Anonymous(notverified)

pleasehelpmetomakeaprogramofamaterialdirectorysystemusingvbanddatabase
inawarehouseofanelectroniccompany

cansomeoneherehelp Thu,08/13/200900:59Anonymous(notverified)

cansomeoneherehelpme...
ineedacodesforloginsystemwithmsaccessdatabaseforvb6withmultipleusers..sendtomyemailpls....
gurl_lovely_28@yahoo.com

com Tue,08/11/200906:20Kiea(notverified)

Iwant

Counter... Fri,08/07/200911:53MikeBlackford(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 59/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Hi,mynameisMikeandIamlookingforcodethatwillcountthelettersinatextbox,thendisplaythenumberof
charactersinalabel.Pleasehelpmeout.Thanks.

INTEXTBOXCHANGE Thu,12/02/201011:41Anonymous(notverified)

INTEXTBOXCHANGESUB

x=len(textbox#)
label#=x

THELABELWILLBEUPDATEDEVERYTIMETEXTBOXCHANGES

Itstoeasy.......... Fri,11/06/200923:51TanmayMajumder(notverified)

Assume....

Youhaveatextboxnamedtext1,andalabelnamedlabel1.

Thenwritethiscodeinthechangeeventofthetextbox.

label1.caption=str(len(me.text1.text))

ifyoudon'twanttocounttheleftspacesthen.

label1.caption=str(len(trim(me.text1.text)))

Thankyou......

Ifyouwantmoreiwillhelpyou.Justmailme.....kingsonprisonic@gmail.com

http://www.vb6.us/tutorials/vb6stringfunctions 60/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

Label1.Caption= Mon,08/17/200908:57Anonymous(notverified)

Label1.Caption=Len(Textbox.text)

Solution Mon,08/17/200908:58Anonymous(notverified)

Label1.Caption=Len(Textbox.text)

Pleasemailmehowtomodifyregistrywithvb6.0 Tue,08/04/200900:31eragon(notverified)

Help!!!!!!!!!
Pleasewriteaprogramtomodifyregistryandsendmecodingforthisprogramandhowtowrite

VB6RegistryFunctions Wed,10/28/200910:24Anonymous(notverified)

VB6hasitsownsetofregistryfunctions.SearchinVB6Help.

Toconvertstringinto Fri,07/17/200910:19Anonymous(notverified)

ToconvertstringintoUpercasethefirstletterandlowercasetherest:

DimstrAsString

http://www.vb6.us/tutorials/vb6stringfunctions 61/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

str="sandiego"
StrConv(str,vbProperCase)

="SanDiego"

Hey,thanksthishelpful Tue,07/07/200906:33Enis(notverified)

Hey,thanksthishelpfuldocuments.
youdidagoodwork.

Limitnumbercharactersinonelineoftextfile Wed,06/17/200914:56Anonymous

INeedhelp!
Ihaveatringas"IamworkingonanewassignmentwithVisualbasic6.0AAAAAAAAAAAAAAAAAAAAAA"
ItrytosplitthestringinTextfileeachlinehavenomorethan15charactersfirst,splitthestringatspacenotinword
second,thewordislongerthan15,splittheword.HowcanImaketheoutputastheonebelow:
Iamworking
onanew
assignmentwith
Visualbasic
6.0
AAAAAAAAAAAAAAA
AAAAAAA
Pleasehelp,Thanksalot...

trythis Tue,09/08/200920:52Anonymous(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 62/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

ifuareusingatextbox,it'sjustsimple,justgotothepropertiesoftextboxthensetthemaxlengthto15andthen
setthemultilinetotrue.ihopei'dhelpyouevenit'stoverylate.hehehe

Extractingdatatilltheend Tue,06/02/200906:25Anonymous(notverified)

IwanttoextractdatathroughVBcode.Wehaveamailandthemailbodycontentisstoredinastordinastring.thereis
tagcalled"description".Descriptiondataisastring,withnospecificlength.Wewanttoextractthatdata.

Currentlyitsgivingthedatabuttruncatingsomewhereinthemiddleandsoamnotgettingthecompletetextpresentin
'description'tag/
Anysuggestionsashowcanwedoit.

Thanks

howtofindthattheperticularcharacterinastringin Sat,05/30/200903:27prasad_renuka(notverified)
null.
higoodmorning,isthestringforexample.8thcharacterisnullbuthowtofindout.

answer Sat,11/28/200906:38rhod(notverified)

gumagamitkbangdatabased2
okkungsadatabase

thiscode...

withadodc1.recordset
.movefirst

http://www.vb6.us/tutorials/vb6stringfunctions 63/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

dowhilenot.eof
iftext1.text=""andlen(text1.text)=8then
exitsub
endif
.movenext
loop

endwith

comparisionoftwoarrays Thu,05/28/200904:05Anonymous(notverified)

Hithecontentofthisarticlewassogoodanduseful...iwanttoknowhowvwillcompareorsearchforoneiteminonearray
withtheanotherarray

forexample:

arrayaconsistsof1,2,3,4,5
arraybconsistsof2,5,7,9

nowiwanttocomparearrayaandbandneedtogetamesageboxas2and5existsinarraya

soanyonecanpleasehelpmeinthis....

thesoulutionofurproblem Mon,11/30/200908:10rodel(notverified)

example.....butconvertintoatext

okfirst
dimaasinteger
dimsasstring
a=a+1
s=text2.text

http://www.vb6.us/tutorials/vb6stringfunctions 64/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

fora=1tolen(text1)
ifinstr(text2.text,text2.text)then
msgboxs&"existingnumber"
s=mid(s,a,1)
endif
next

takenoteyoumustconvertintoarray

answer Sat,11/28/200906:31rhod(notverified)

okinamsgboxyoumustvariablethenumberexistexample
ifa=bthen
msgboxa&b&"isalreadyexist"
else
exitsub
endif

likedat'oklater....iwillgiveyouaprogrammlikedat'''

dimi,k,xasintergerdim Sun,05/31/200916:53Anonymous(notverified)

dimi,k,xasinterger
dimarrayCasinteger
x=0
fori=0toubound(arrayA)
fork=0toubound(arrayB)
ifarrayB(k)=arrayA(i)then
arrayC(x)=arrayB(k)
x=x+1
endif
http://www.vb6.us/tutorials/vb6stringfunctions 65/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

next
next

arrayCwillcontainvaluesthatarerepeatedinbotharrays.(iefortheexamplearraysyouprovidedarrayCwillcontain
(2,5)

thankyou Thu,05/21/200908:23Anonymous(notverified)

thankyou

needanequivalentto Tue,05/12/200911:38djcowbell(notverified)

needanequivalenttofoxpro'spadleft?

CodeforseprtatecharacterAndNumberfromString Mon,05/04/200923:30RakeshThakre(notverified)

thebelowcoderemovethecharacterandnumberindiviuallyduetothatwecaneasilysepratedthenumbersandstring...

codeasbelow

DimrevsAsString
Dimstr1AsString
Dimstr2AsString
revs=StrReverse(txtChanginItemCode.Text)
str2=StrReverse(Val(revs))
str1=StrReverse(Replace(revs,StrReverse(str2),""))

http://www.vb6.us/tutorials/vb6stringfunctions 66/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

referencesneededforstringfunctions Fri,04/10/200902:32Anonymous(notverified)

Invb6doIneedtoincludeanyreferencestoallowmetousethesestringfunctions.

TooHelpful Wed,04/01/200904:49profcharles

Theinformationcontainedthereinisveryhelpfulbothasreferenceorforreadingandstudypurposes.Thisshouldbe
awardedSITEOFTEYEAR2009.:)

Charles

checkforparticularstringagainstasetofvalues Wed,04/01/200900:04Indu(notverified)

ineedtocheckforaparticularstringagainstasetofstringvalues:Cananybodyhelpmeinthis

eg:

IfarrayCol(k,0)<>"do"or"jo"or"uo"Then
MsgBox"DepartmentcannotbeNull.LineNo."&totItems,vbCritical,"ALERT"
Else

Trythis Mon,04/27/200915:35shAnk5(notverified)

http://www.vb6.us/tutorials/vb6stringfunctions 67/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

]
IfarrayCol(k,0)="do"orarrayCol(k,0)="jo"orarrayCol(k,0)="uo"Then
...
Else
MsgBox"DepartmentcannotbeNull.LineNo."&totItems,vbCritical,"ALERT"
EndIf

Hey,howwouldI Tue,03/31/200909:51Anonymous(notverified)

Hey,howwouldI"CONCATENATE"inVB?
SayIneedtoadd"A"tothebeginningofthestringinCellA1andthenloopittilltheend.
Thanksinadvance!

Operator&or+,avaibleinhelpfile Wed,04/01/200911:03Anonymous(notverified)

&or+
"thecat"&"thehat"="thecatthehat"
Var="file"
Var&".dat"="file.dat"

NetworkSecurity Mon,03/09/200900:27VISHAL(notverified)

Articleisquitenice.coversallfunctionsrelatedtostring,

http://www.vb6.us/tutorials/vb6stringfunctions 68/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

VBcodes Fri,02/27/200921:45Anonymous(notverified)

\Yuyoursiteisreallyhelpful.pleasesendmeacompletelistandthecodesusedinVBanditsfunction.

Thathankyouverymuch.

Howcaniselectastringbetweeneg.<!and> Wed,02/25/200909:03walkytalky

Hitoall,

Howcaniselectastringbetweeneg.

str1=function(<"!Thereisacomment>")
str1shouldgiveme"Thereisacomment"

Yourssincerely,

WalkyTalky

howtoselectstringbetweenfixedprefixandsuffix Tue,03/24/200905:02matangur

iftheprefixandsuffixarefixed,itwouldbemucheasiertodothis:

str1=mid([comment],5,len(comment)9)

where:
comment>themanipulatedcomment(thewholestring)
5>thepositioninwhichthecommenttextstarts
len(comment)9>thelengthofthewholecommentlesstheprefix+suffix.resultswiththetextlength.

hopeitwashelpful

http://www.vb6.us/tutorials/vb6stringfunctions 69/70
2/12/2017 VisualBasic6StringFunctions|VisualBasic6(VB6)

1 2 next last

Unlessotherwisenoted,allcontentonthissiteandinthesourcesamplesisCopyrighted2011bytheownerofvb6.us.
AllrightsreservedContactInformation

http://www.vb6.us/tutorials/vb6stringfunctions 70/70

You might also like