problem with VB6 code

Discussion in 'Programmer's Corner' started by ravinaval, Apr 14, 2012.

  1. ravinaval

    Thread Starter New Member

    Apr 14, 2012
    7
    0
    - I m using P89V51RD2
    I want to read data from PORT-2 of microcontroller using VB-6 software

    while reading data form port, VB-6 shows the ASII value of the data but I want the decimal value

    PLEAZ HELP
     
  2. ravinaval

    Thread Starter New Member

    Apr 14, 2012
    7
    0
    please help me in wrting code in VB-6.0 for reading the data from port of P89V51RD2 and displaying the exact decimal equivalent of data at the port.

    storing it into the data and den displaying it in VB6.0


    PLZ HELP
     
  3. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    Use the ASC function.
     
  4. ravinaval

    Thread Starter New Member

    Apr 14, 2012
    7
    0
    ASC function is not working in our case

    this is my code , plz suggest me or give me modified code


    Public i As Integer
    Dim values() As Integer
    Public Temp_In As Variant
    Public Data_In As Variant
    Dim k As Variant
    Public j As Integer

    Private Sub Form_Load()

    MSComm1.PortOpen = True

    End Sub

    Private Sub MSComm1_OnComm()
    Temp_In = MSComm1.Input

    Text1.Text = Text1.Text & Temp_In
    Data_In = Asc(Temp_In)
    Text2.Text = Text2.Text & Data_In


    End Sub
     
  5. ravinaval

    Thread Starter New Member

    Apr 14, 2012
    7
    0
    plz rely coderzzzzzzzzzzzz
    ....................
     
  6. DumboFixer

    Active Member

    Feb 10, 2009
    219
    34
    What numbers are you getting and what are you expecting ?
     
  7. ravinaval

    Thread Starter New Member

    Apr 14, 2012
    7
    0

    I am giving data = 0011 1001=(39)"hexadecimal" at port -2 of of microcontroller
    but Im getting ascii value of 39HEX ie 9 at the hyperterminal and as well as VB-6 gui textbox.

    I want the same number 39 in my GUI.

    thanku
     
    Last edited: Apr 15, 2012
  8. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    0011 1001 is not 39- decimal
    It is 57-decimal = ASCII "9"

    There are 10 types of people in the world, those who understand binary and those who don't.
     
  9. ravinaval

    Thread Starter New Member

    Apr 14, 2012
    7
    0
    sorry
    I mean I want to display 57 which is decimal equivalent of data at port 2 of my uc
     
  10. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    Write a routine on the MCU equivalent to num2str(int d).
    It is not difficult.
     
  11. ravinaval

    Thread Starter New Member

    Apr 14, 2012
    7
    0

    I hav written my code above pls tell me where shud i make change
     
  12. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    Can't see the code.
     
  13. panic mode

    Senior Member

    Oct 10, 2011
    1,321
    304
    MrChips, i'm surprised... ;)
     
  14. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    Surprised with?
     
  15. panic mode

    Senior Member

    Oct 10, 2011
    1,321
    304
    involvement
     
  16. MrChips

    Moderator

    Oct 2, 2009
    12,449
    3,365
    I steer people in the right direction but I don't follow them.
     
  17. DumboFixer

    Active Member

    Feb 10, 2009
    219
    34
    Why not use the str function ?

    This will convert a number into a string so 59 will become "59".

    The application help will tell you how to use the str function.
     
Loading...