Results 1 to 2 of 2

Thread: Simple VB6 question

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2002
    Posts
    1

    Simple VB6 question

    I am using ADO, am pulling a small recordset (2 columns, 2-8 rows max). One column is a description of a charge, and the other is the actual charge itself. I am needing to cycle through this rs and insert these charges into variables, as I am then putting these variables into an email and sending it off. I cannot figure out how to cycle through the rs, creating the number of variables to match the # within the rs, and then get these variables out to the main loop where I add them to the body of the email. Please help, its prob really simple, but I cant seem to figure out how. My main procedure is a do loop, and I think I need to nest the "charge code" within it. I think I need to use a 2 dim array, but cant figure it out...I am fairly new, please help.

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Omaha, NE
    Posts
    270
    Here is something to perhaps get you started.
    VB Code:
    1. Dim strArray() As String
    2.     Dim x As Integer
    3.     Dim strMailMessage As String
    4.    
    5.     x = -1
    6.     'This section reads records & puts field data
    7.     'into a dynamic 2 dimensional array
    8.     With RecordsetName
    9.         .MoveFirst
    10.         Do Until .EOF
    11.             x = x + 1
    12.             ReDim Preserve strArray(1, x)
    13.             strArray(0, x) = !Field1Name
    14.             strArray(1, x) = !Field2Name
    15.             .MoveNext
    16.         Loop
    17.     End With
    18.    
    19.     'This section reads the values in the array & concatenates them into
    20.     'a variable (each record's values separated by a tab & each record on
    21.     'a separate line) for use in the Message part of an email
    22.     For x = 0 To UBound(strArray, 2)
    23.         strMailMessage = strMailMessage & strArray(0, x) & vbTab & _
    24.             strArray(1, x) & vbCrLf
    25.     Next x
    26.      
    27.     'Section to create email....

    Hope this helps.
    Nate

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