Web Analytics Made Easy -
StatCounter Visual Basic overwriting variable - CodingForum

Announcement

Collapse
No announcement yet.

Visual Basic overwriting variable

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Visual Basic overwriting variable

    I want to be able to parse a string like this
    sInput ="BLAH BLAH BLAH; PARSE_THIS1-BLAH BLAH BLAH; PARSE_THIS2-BLAH BLAH BLAH; PARSE_THIS3-BLAH BLAH BLAH; PARSE_THIS4-BLAH BLAH BLAH; PARSE_THIS5-BLAH BLAH BLAH; PARSE_THIS6-BLAH BLAH BLAH; PARSE_THIS7-BLAH BLAH BLAH; PARSE_THIS8-BLAH BLAH BLAH;"

    and have it display in another (multi-line) text box named txtResult. I've got the parsing part of my code correct. The problem I am having is that I am overwriting the value of temp2. and only displaying the last value in my txtResult textbox. Its been forever and a day since I've actually programmed...

    Code:
    Option Explicit
    Dim sInput As String
    Dim temp
    Dim temp2
    Dim arr()
    Dim arr2()
    sInput ="BLAH BLAH BLAH; PARSE_THIS1-BLAH BLAH BLAH; PARSE_THIS2-BLAH BLAH BLAH; PARSE_THIS3-BLAH BLAH BLAH; PARSE_THIS4-BLAH BLAH BLAH; PARSE_THIS5-BLAH BLAH BLAH; PARSE_THIS6-BLAH BLAH BLAH; PARSE_THIS7-BLAH BLAH BLAH; PARSE_THIS8-BLAH BLAH BLAH;"
    Private Sub cmdEnter_Click()
    sInput = txtInput.Text
    'MsgBox (sInput)
    arr = Split(sInput, "-")
    For Each temp In arr
        MsgBox (temp)
        arr2 = Split(temp, ";")
        temp2 = arr2(1) & vbCr
        txtResult.Text = temp2
    Next
    End Sub
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #2
    Set it to the previous value concatenated with the new value:
    txtResult.Text = txtResult.Text & temp2

    Good luck;
    -Brando
    Why using tables for eating is stupid!

    Comment


    • #3
      WoW! Actually all I had to do was what every great programmer does when faced with a problem.....take a break. Thanks Brandoe.
      Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

      Comment

      Working...
      X