Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

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!

0
GlobalFax
Asked:
GlobalFax
1 Solution
 
JacamarCommented:
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
0
 
JacamarCommented:
I know it doesn't look so great, but it will get the job done.
0
 
JacamarCommented:
sorry,

Call msgbox (mylaststring, vbinformation)

add this instead of the Text2.text = mylaststring
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
JacamarCommented:
sorry, you need something else too.
0
 
bobbit31Commented:
'' 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
0
 
supunrCommented:
Why is this question worth such a high number of points? Is there any tricks to this question.  Previous answer is perfectly correct.
0
 
tWiZtEr_RXCommented:
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
0
 
bobbit31Commented:
wow, looks familiar ;)
0
 
GlobalFaxAuthor Commented:
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!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now