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

    Ok, different question. How do I put 2 received bytes back together to make 1 word?
    -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
    Ok, different question. How do I put 2 received bytes back together to make 1 word?
    Tell me one thing first, what is the type of you variable where you receive the data from PIC, Integer, String....
    Thanks and Regards;
    Gadelhas

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


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    Like you did have to be fine.
    WordOut=(MSByte*256)+LSByte
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    Quote Originally Posted by mister_e View Post
    Like you did have to be fine.
    WordOut=(MSByte*256)+LSByte
    That should work;

    But if you are showing this result to a textbox you should do
    this:
    WordOut=(MSByte*256)+LSByte
    czhb.Text=WordOut.ToString

    Maybe it is not your problem, but you should do this!
    Thanks and Regards;
    Gadelhas

  5. #5
    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!

  6. #6
    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

  7. #7
    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!

  8. #8
    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.

  9. #9
    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!

  10. #10
    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.

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