xaviorg
04-23-2003, 12:40 PM
ok, how can i make a function that can add STRING1 to STRING2 every 8 characters? example: if STRING2 was "aaaaaaaahhhhhhhhk", it would come out to be "aaaaaaaaSTRING1hhhhhhhhSTRING1k", any help will be appreciated
|
Click to See Complete Forum and Search --> : Visual Basic Question xaviorg 04-23-2003, 12:40 PM ok, how can i make a function that can add STRING1 to STRING2 every 8 characters? example: if STRING2 was "aaaaaaaahhhhhhhhk", it would come out to be "aaaaaaaaSTRING1hhhhhhhhSTRING1k", any help will be appreciated khalidali63 04-23-2003, 01:16 PM If I rememeber correctly,it is Mid function that lets you do something like this...read about this function.. xaviorg 04-23-2003, 01:35 PM yes, but that replaces the characters in the string already, example: i need to move "hhhhhhhh" over lets say 7 spaces first to plug in STRING1 like this: "aaaaaaaaSTRING1hhhhhhhh", not like this: "aaaaaaaaSTRING1h" khalidali63 04-23-2003, 02:12 PM Yes,.well nevermind, Take a look here,it probably the best resource out there for VB crap...You may have to go through allots of links to find a desired solution.. good luck (unfortunately I won't be able towrite something for you at least today and tomorrow) http://www.freevbcode.com/listcode.asp?Category=9 good luck khaki 04-23-2003, 02:37 PM hi xaviorg... this is done using MID (or it can be done that way). Sub stringThing() howLong = Len("aaaaaaaahhhhhhhhk") finalChars = howLong - 16 strFirst8 = Left("aaaaaaaahhhhhhhhk", 8) strSecond8 = Mid("aaaaaaaahhhhhhhhk", 9, 8) strLast = Right("aaaaaaaahhhhhhhhk", finalChars) strFinishedString = strFirst8 & "STRING1" & strSecond8 & "STRING2" & strLast Range("a1").Value = strFinishedString End Sub you can obviously condense that dramatically... (and do it in any number of ways)... but this breaks it down into some of it's many different possible parts (and is written here as VBA for Excel for testing purposes). hope this helps you understand the logic of the different methods. ;) k xaviorg 04-23-2003, 04:40 PM yes, thank you, this has helped me better understand the Mid() function, after a bit of deep thinking, i came up with this: theString = "aaaaaaaahhhhhhhhk" j = 0 Dim theStringParts(0 To 100) As String firstRun = True For i = 1 To Len(theString) Step 8 theStringParts(j) = Mid(theString, i, 8) j = j + 1 Next i theString = vbNullString For i = 0 To j If firstRun = True Then theString = theStringParts(i) firstRun = False Else theString = theString + "TESTBREAK" + theStringParts(i) End If Next i MsgBox theString its working, thankfully, thanks for taking the time to help me out khaki 04-23-2003, 04:54 PM oh shoot! you had me thinking that you were a newbie at VB :rolleyes: sorry for dumbing-you-down with the primitive drawn-out example... i thought you needed it that way :eek: cool. your set (i guess... i didn't test it... but you did... so...) and just for future references... this type of question can go into the ASP forum (everybody writes VB of some form there) once again... sorry for not just giving you a mean and clean version... i really thought that you were a newb and were in need of examples of the concepts in order to learn :rolleyes: ;) k xaviorg 04-23-2003, 05:37 PM lol, its no problem, a lot of people think im a newb, but its ok, my script apparently works, thanks for helping! xaviorg 04-23-2003, 06:55 PM ok, its now a published module, you can get it at: http://www.vbcode.com/Asp/showsn.asp?theID=8821 webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |