Results 1 to 3 of 3

Thread: How to store data in a string?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2004

    How to store data in a string?

    I need to use a 3rd party function to write data into a device. The function syntex require to provide a string:

    writeto( string )

    However, the data that I want to write is a record structure consist of

    r1 char[1]
    r2 char[1]
    r3 int[1]
    r4 datetime[1]
    r5 char[1]
    r6 char[2]
    r7 char[2]

    Can someone teach me how to change this data into a single string in VB so that I can use the function.


  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Ulaan Baator GooGoo: Frog
    Loop through the recordset, and CStr() all the values.

    Somewhat like:

    VB Code:
    1. 'PseudoCode!
    2. Dim intColCount As Integer
    3. Dim intCounter as Integer
    4. Dim strSomething As String
    6. intColCount = 'number of columns
    7. For intCounter = 0 to intColCount - 1
    9. strSomething = strSomething & CStr(rs.Fields(intCounter).Value)
    11. Next intCounter

    See what I'm hitting at?

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2004

    Sorry for I forget to mention one more point. The length of the resulting string is limited to 16 byte. Therefore I have to store the date/time value ( and all other value ) in it's original binary format ( 8-bytes for date time, 2-byte for integer, etc ). If I use the cstr, it will be too long.

    Would you mind to help me again.

Posting Permissions

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

Click Here to Expand Forum to Full Width