Hello World
I have a program and an access as back end. On my Subject table, I set Units (Field name) to Number as datatype with the following properties (Field Size=Integer, Format=Fixed, Decimal Places=1)
The results on the database were fine
Units
5.0
4.0
6.0
2.0
...
But when I retrieve them on vb6.0, the results was not the same as on access.
Units
5
4
2
2
...
I tried to change the units to double but still the same.
Here's my sample codes
[code=vb]
rs.Open "Select * From Subject", cn, 1, 1
list.ListItems. Clear
While Not rs.EOF
On Error Resume Next
With list.ListItems. Add(, , rs!SubjectID, img1, img2)
.SubItems(1) = rs!Subject
.SubItems(2) = rs!Units
'...... and so on...
End With
rs.MoveNext
Wend
[/code]
So what I did was:
[code=vb]
rs.Open "Select * From Subject", cn, 1, 1
list.ListItems. Clear
While Not rs.EOF
On Error Resume Next
With list.ListItems. Add(, , rs!SubjectID, img1, img2)
.SubItems(1) = rs!Subject
.SubItems(2) = rs!Units & ".0"
'...... and so on...
End With
rs.MoveNext
Wend
[/code]
I think that my second code is not really bad, I know there's really solution for these. Can anyone help me to find it how?
I tried Cdbl but nothing happens : (
I have a program and an access as back end. On my Subject table, I set Units (Field name) to Number as datatype with the following properties (Field Size=Integer, Format=Fixed, Decimal Places=1)
The results on the database were fine
Units
5.0
4.0
6.0
2.0
...
But when I retrieve them on vb6.0, the results was not the same as on access.
Units
5
4
2
2
...
I tried to change the units to double but still the same.
Here's my sample codes
[code=vb]
rs.Open "Select * From Subject", cn, 1, 1
list.ListItems. Clear
While Not rs.EOF
On Error Resume Next
With list.ListItems. Add(, , rs!SubjectID, img1, img2)
.SubItems(1) = rs!Subject
.SubItems(2) = rs!Units
'...... and so on...
End With
rs.MoveNext
Wend
[/code]
So what I did was:
[code=vb]
rs.Open "Select * From Subject", cn, 1, 1
list.ListItems. Clear
While Not rs.EOF
On Error Resume Next
With list.ListItems. Add(, , rs!SubjectID, img1, img2)
.SubItems(1) = rs!Subject
.SubItems(2) = rs!Units & ".0"
'...... and so on...
End With
rs.MoveNext
Wend
[/code]
I think that my second code is not really bad, I know there's really solution for these. Can anyone help me to find it how?
I tried Cdbl but nothing happens : (
Comment