|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Using the replace command, please helpstring variable so that replacing Rdgpc-test = 1dgpc-test, and this works fine Dim strcomputer, strcomputer1 Strcomputer = "rdgpc-test" Strcomputer1 = (Replace(strcomputer,"R", "1")) msgbox strcomputer1 However If strcomputer = "rdgpc-Rdgtest" then the result = 1dgpc-1dgtest Is their anyway I can replace just the first instance, or just the first character?? I have not been able to find anyway to do this and yet it seems like such a simple task. Any help would be greatly appreciated. Thanks in advanced Chris
Show quote
Hide quote
"Chris" <chris_simon_***@yahoo.com> wrote in message How did you search for a way to do it? Did you try looking at the help ornews:1142032422.952149.117600@e56g2000cwe.googlegroups.com > In the following script I use the replace command to change R to 1 in > a string variable so that replacing Rdgpc-test = 1dgpc-test, and this > works fine > > > Dim strcomputer, strcomputer1 > Strcomputer = "rdgpc-test" > Strcomputer1 = (Replace(strcomputer,"R", "1")) > msgbox strcomputer1 > > > However If strcomputer = "rdgpc-Rdgtest" then the result = > 1dgpc-1dgtest > > Is their anyway I can replace just the first instance, or just the > first character?? > > I have not been able to find anyway to do this and yet it seems like > such a simple task. the intellisense for Replace? replace(expression,find,replace,[start],[count],[method]) -- Reply to the group so all can participate VB.Net: "Fool me once..."
Show quote
Hide quote
"Chris" <chris_simon_***@yahoo.com> wrote in message In VB6, it would be.....news:1142032422.952149.117600@e56g2000cwe.googlegroups.com... > In the following script I use the replace command to change R to 1 in a > string variable so that replacing Rdgpc-test = 1dgpc-test, and this > works fine > > > Dim strcomputer, strcomputer1 > Strcomputer = "rdgpc-test" > Strcomputer1 = (Replace(strcomputer,"R", "1")) > msgbox strcomputer1 > > > However If strcomputer = "rdgpc-Rdgtest" then the result = > 1dgpc-1dgtest > > Is their anyway I can replace just the first instance, or just the > first character?? > > I have not been able to find anyway to do this and yet it seems like > such a simple task. > > Any help would be greatly appreciated. > > Thanks in advanced > > Chris '======= Private Sub Form_Load() Dim sTest As String sTest = "rdgpc-Rdgtest" Debug.Print Replace$(sTest, "r", "1", 1, 1) '<-shows 1dgpc-Rdgtest End Sub '======= Not sure about script Another way... just chop off the first character. '======= Private Sub Form_Load() Dim sTest As String sTest = "rdgpc-Rdgtest" sTest = "1" & Mid$(sTest, 2) Debug.Print sTest 'shows 1dgpc-Rdgtest End Sub '======= -- Ken Halter - MS-MVP-VB - Please keep all discussions in the groups.. DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm Thanks for the help Ken, that was so much easier then using the replace
command. Here is how I did the code for vbscript, very similar. Dim strcomputer, strcomputer1 Strcomputer = "rdgpc-test" Strcomputer1 = "1" & mid(strcomputer, 2) msgbox strcomputer1 Thanks again, I really appreciate the help Chris "Chris" <chris_simon_***@yahoo.com> wrote in message The best way would be to type the word Replace into your code and hit the F1 news:1142032422.952149.117600@e56g2000cwe.googlegroups.com... > However If strcomputer = "rdgpc-Rdgtest" then the result > 1dgpc-1dgtest Is their anyway I can replace just the first > instance, or just the first character?? key ;-) Mike
Why ?? (Path/File access error (Error 75)
VB.NET or C++.NET or C# Password Change TransparentBlt and Autoredraw issues (refresh isnt solving it) Picturebox fit newbe question NTFS File Access in VB6 Sub or Function is not defined Control similar to MS Access List Box write to disk and permissions re-use code for multiple applications |
|||||||||||||||||||||||