|
-
Jul 2nd, 2002, 10:42 AM
#1
Thread Starter
New Member
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.
-
Jul 2nd, 2002, 11:05 AM
#2
Hyperactive Member
Here is something to perhaps get you started.
VB Code:
Dim strArray() As String
Dim x As Integer
Dim strMailMessage As String
x = -1
'This section reads records & puts field data
'into a dynamic 2 dimensional array
With RecordsetName
.MoveFirst
Do Until .EOF
x = x + 1
ReDim Preserve strArray(1, x)
strArray(0, x) = !Field1Name
strArray(1, x) = !Field2Name
.MoveNext
Loop
End With
'This section reads the values in the array & concatenates them into
'a variable (each record's values separated by a tab & each record on
'a separate line) for use in the Message part of an email
For x = 0 To UBound(strArray, 2)
strMailMessage = strMailMessage & strArray(0, x) & vbTab & _
strArray(1, x) & vbCrLf
Next x
'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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|