String Conversion


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2006
    Posts
    22

    Post String Conversion

    I have a two bytes string (data array)

    data[0]=9
    data[1]=8

    how can I get from this string array the number in to a variable ?

    data_var = 89

    ???


  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Code:
    T = data[1] 'Tens
    O = data[0] 'Ones
    data_var = (T*10)+O
    Maybe??
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Jul 2006
    Posts
    22


    Did you find this post helpful? Yes | No

    Default

    Pretty simple, just convert to number the ascii content

    Code:
    T = data[1]  - 48 'Tens
    O = data[0]  - 48    'Ones
    data_var = (T*10)+O
    and it work for me, Thanks mackrackit.

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Code:
    T = data[1] 'Tens
    O = data[0] 'Ones
    data_var = (T*10)+O
    Maybe??
    Hi Dave,
    doesn't this work ?
    data[0] = "T"
    data[1] = "O"
    or did I miss the point (again) entirely? OK, yes I did! I thought he wanted to store ascii characters in the array.
    Last edited by Archangel; - 19th August 2009 at 21:01.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

Similar Threads

  1. How about String Variables?
    By mytekcontrols in forum PBP Wish List
    Replies: 40
    Last Post: - 20th January 2015, 13:53
  2. A/D conversion with PIC18F67J50
    By ScaleRobotics in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 8th May 2009, 02:48
  3. How to convert HEX Value as formatted BIN String ?
    By Robson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th August 2007, 03:16
  4. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 05:39
  5. int to string conversion
    By guanerrr in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 24th December 2005, 03:00

Members who have read this thread : 1

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