Link to home
Start Free TrialLog in
Avatar of GlobalFax
GlobalFax

asked on

Parsing txtInputString into a string type variable

Here's my scenario:

I need to create a text box named (for example) "txtInputString01".  The text box, in this example will type in "SuperCaliFragaSomethingOrAnother"

I need to create a button that when clicked evaluates the content of (in this example) the "txtInputString01" and parses it into a string type variable which is displayed in a MsgBox containing the left-most character of the string, plus the 6th through 9th characters, plus the last 7 characters.

Thanks in advance!

Avatar of Jacamar
Jacamar

Private Sub Command2_Click()
Dim ststring As String
Dim mystring As String
Dim mylaststring As String

ststring = Text1.Text

mystring = Mid(ststring, 1, 1)
mylaststring = mystring

mystring = Mid(ststring, 6, 4)
mylaststring = mylaststring & mystring

mystring = Mid(ststring, inCounter - 6, 7)
mylaststring = mylaststring & mystring

Text2.Text = mylaststring
End Sub
I know it doesn't look so great, but it will get the job done.
sorry,

Call msgbox (mylaststring, vbinformation)

add this instead of the Text2.text = mylaststring
sorry, you need something else too.
ASKER CERTIFIED SOLUTION
Avatar of bobbit31
bobbit31
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Why is this question worth such a high number of points? Is there any tricks to this question.  Previous answer is perfectly correct.
Private Sub Command1_Click()
' get string from textbox
Dim strText As String
Dim strParsed As String

strText = txtInputString01.Text
strParsed = Left(strText, 1) & Mid(strText, 6, 3) & Right(strText, 7) ' get left most, 6-9, and last 7 chars
MsgBox strParsed ' msgbox it
End Sub
wow, looks familiar ;)
Avatar of GlobalFax

ASKER

Perfect answer!  I already had button name so I just had to make a name change!

As for why so many points?  No trick, I'm just in a good mood!

Thanks to all!