VB Help


Closed Thread
Results 1 to 36 of 36

Thread: VB Help

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    Well not saying its is the best way by any means, but this seems to work:
    Code:
    Dim i AsInteger
    Dim t AsUShort
    Dim datain AsByte
    Dim data(20) AsByte
    Dim sign AsString
    
     
    t = (data(0) * 256) + data(1)
    If t > 32767 Then
      t = (Not t) + 1
      sign = "-"
    Else : sign = " "
    EndIf
    gxhb.Text = sign & t.ToString
    Thanks for the help guys, for now this will cover my needs
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Aug 2008
    Location
    Portugal
    Posts
    240


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    Quote Originally Posted by cncmachineguy View Post
    Well not saying its is the best way by any means, but this seems to work:
    Code:
    Dim i AsInteger
    Dim t AsUShort
    Dim datain AsByte
    Dim data(20) AsByte
    Dim sign AsString
    
     
    t = (data(0) * 256) + data(1)
    If t > 32767 Then
    t = (Not t) + 1
    sign = "-"
    Else : sign = " "
    EndIf
    gxhb.Text = sign & t.ToString
    Thanks for the help guys, for now this will cover my needs

    Yeh, that works, and if it works...GooD
    Thanks and Regards;
    Gadelhas

  3. #3
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    Seems like it should be much easier.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    yeah but where would be the fun
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    Well I guess it would be a little better if that snippet was a sub routine, or function, or module, or object. See, I don't even know what it should be.

    To me a sub-routine. I want to call it with values in data1 and data2. it should return with a string in wordout.

    But that is just a little above my pay grade right now.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    Once you feel you're ready, have a look at this
    http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx

    Then you could use something like
    txtResult.txt = ConvertWordToSignedString (WordVariable)
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  7. #7
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    Hot Dog!! Thanks again, I feel proud

    new function:
    Code:
    PublicFunction CreateSWord(ByVal data1 AsByte, ByVal data2 AsByte) AsString
      Dim t AsUShort
      Dim sign AsString
    
         t = (data1 * 256) + data2
         If t > 32767 Then
            t = (Not t) + 1
            sign = "-"
         Else
            sign = " "
         EndIf
    Return (sign & t.ToString)
    EndFunction
    And how to get there:
    Code:
    gxhb.Text = CreateSWord(data(0), data(1))
    gyhb.Text = CreateSWord(data(2), data(3))
    gzhb.Text = CreateSWord(data(4), data(5))
    axhb.Text = CreateSWord(data(6), data(7))
    ayhb.Text = CreateSWord(data(8), data(9))
    azhb.Text = CreateSWord(data(10), data(11))
    cxhb.Text = CreateSWord(data(12), data(13))
    cyhb.Text = CreateSWord(data(14), data(15))
    czhb.Text = CreateSWord(data(16), data(17))

    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    See how easy it is now huh?

    Well done!
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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