dcsimg
Results 1 to 5 of 5

Thread: How to add data in a variable

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2007
    Location
    Lictin
    Posts
    36

    How to add data in a variable

    Hi guys, im having trouble with my script about data adding to a variable, here is the scenario :

    dim buff as string,message1 as string,message2 as string _
    combineMessage as string,realMess as string
    buff = "" <--- initial variable

    for x = 1 to 10
    message1=mid(realMess,x,1)
    combineMessage=message1 & buff <--- combine the two message
    buff=left(combineMessage,2) <--- get the data to be added for the next loop
    next

    what i wanted is after getting the buff data, its contents will be added to the combineMessage after the next loop, but what happens is the same buff data i being generated.

  2. #2
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: How to add data in a variable

    What is in RealMess? I don't see anything being put into it.

    What exactly do you want to achieve with this code?

  3. #3

    Thread Starter
    Member
    Join Date
    Sep 2007
    Location
    Lictin
    Posts
    36

    Re: How to add data in a variable

    hi jeroen, what i wanted is for the buff variable found at the end of the script,
    to be added in the next loop, for example, at the first run of the loop, the value of buff = "", after the second loop, the value will buff="something", then after the 3rd loop, buff="somethingNewsomething" until the end of the loop, data just keeps on appending to the buff variable.

  4. #4
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: How to add data in a variable

    Where is it supposed to get all the somethings?

  5. #5

    Thread Starter
    Member
    Join Date
    Sep 2007
    Location
    Lictin
    Posts
    36

    Re: How to add data in a variable

    Hi jeroen, here is my actual script

    Private Function DecodeHex(ByVal dstr As String) As String
    Dim bStr As String, xl As Long, chopMes As String, mStr As String, strtP As Long, realMes As String, mesStr As String _
    , bit1 As String, bit2 As String

    bStr = ""
    For xl = 1 To Len(dstr) Step 2
    bit1 = HextoBin(Mid(dstr, xl, 1))
    bit2 = HextoBin(Mid(dstr, xl + 1, 1))
    chopMes = bit1 & bit2
    mStr = chopMes & bStr 'combined bits
    strtP = Len(mStr) - 6
    realMes = Mid(mStr, strtP, 7)

    bStr = bStr & Mid(mStr, 1, strtP - 1) 'get bit adder <---data not adding here

    'convert bin data to dec
    Dim xc As Integer, decN As Long
    mesStr = mesStr & Chr(calcbin2den(realMes))
    Next
    DecodeHex = mesStr
    End Function

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width