VB Help


Closed Thread
Results 1 to 36 of 36

Thread: VB Help

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    I never had any purpose to justify the use of signed<->unsigned conversion myself, but you may have a look at
    http://support.microsoft.com/kb/189323

    It's all about how you interpret/display the numbers... like Floating point in PBP... or show decimal on a LCD
    Steve

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

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


    Did you find this post helpful? Yes | No

    Default Re: VB Help

    I would normally side with you steve, but on this one I am having issues. The numbers bounce around zero, so I get to watch 3,3,4,2,1,65533,65534,4,1,.....

    Seems like it would be better to have the numbers more right
    -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!

  3. #3
    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
    From PIC:
    data(0) and data(1). these 2 bytes are the highbyte and lowbyte of a word. -32768-32767

    I need to see the word like that. for example the word may equal 3, or it may be -3. right now I will see 3 or 65533.

    So how to put the bytes back together and show signed integer?
    IN VB.Net, signed bytes are Sbyte and signed Words are Short

    Exemple;
    Dim data0 as Short=-32500
    Dim data1 as SByte = -65

    But if the PIC is sending the 65533, the PC will see 65533 and not -3. Don't know if can help you.
    Last edited by gadelhas; - 30th May 2011 at 23:51.
    Thanks and Regards;
    Gadelhas

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

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

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

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

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

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

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

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