Need to change checkbox Yes/No value to an integer 1 or 0 In recordset usning VB6

Through a SQL select I have 7 fields I am getting data from, two of the fields are boolean, these two field values need to be change from True/False to 1 or 0. The data is coming from an Access table.
Is there a way of changing these data values in my recordset?

See attached code (Done in VB6)

Thanks for your help
I need to change rs2(5) and rs2(6) to a 1 or 0 depending on the boolean value.
________________________________________________________________________
While Not rs2.EOF
'Fields are stored in array
finalData2 = rs2(0) & "," & rs2(1) & "," & rs2(2) & "," & rs2(3) & "," & Chr(34) & rs2(4) & Chr(34) & "," & rs2(5) & "," & rs2(6)
'Print finalData2
Print #2, finalData2
rs2.MoveNext
Wend

Open in new window

rfgrahamAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PaulHewsCommented:
The IIF function can evaluate it in one line as long as neither field is Null.  (I assume you want 1 if true and 0 if false.)

finalData2 = rs2(0) & "," & rs2(1) & "," & rs2(2) & "," & rs2(3) & "," & Chr(34) & rs2(4) & Chr(34) & "," & IIF(rs2(5), "1", "0") & "," & IIF(rs2(6), "1", "0")
0
GrahamSkanRetiredCommented:
Perhaps you can just take the negative of the results:

finalData2 = rs2(0) & "," & rs2(1) & "," & rs2(2) & "," & rs2(3) & "," & Chr(34) & rs2(4) & Chr(34) & "," & -rs2(5) & "," & -rs2(6)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rfgrahamAuthor Commented:
Well, before I checked EE for any expert comments I came up with this and it worked fine:

finalData2 = rs2(0) & "," & rs2(1) & "," & rs2(2) & "," & rs2(3) & "," & Chr(34) & rs2(4) & Chr(34) & "," & Abs(rs2(5)) & "," & Abs(rs2(6))

I also ran PaulHews but it didn't work.
I ran Graham Skan's and it work just fine. Will my solution cause me any problems if I go with it?

Thanks
0
23637269Commented:
'Structure of Database
' rs.FirstName
' rs.LastName
' rs.Available  Yes/No

Dim sInfo As String

With rsDatabase
    Do While Not .EOF
      sInfo = "" 'Clear For New Record
      sInfo = sInfo & Str(.FirstName)
      sInfo = sInfo & ","
      sInfo = sInfo & Str(.LastName)
      sInfo = sInfo & ","
     
      'You can treat a Boolean as yes/no true/false with If Statement
      'You can pass whatever is in the database:
      sInfo = Str(.Available)
     
      'Or
      'You can customize
      If .Available Then
        'True
        sInfo = sInfo & "1" 'Set To Yes or Whatever you want.
      Else
        'False
        sInfo = sInfo & "0" 'Set To Yes or Whatever you want.
      End If
    Print #2, sInfo
    .MoveNext
    Wend
End With
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.