By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,988 Members | 1,493 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,988 IT Pros & Developers. It's quick & easy.

Asking for better solution

lotus18
100+
P: 866
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
Expand|Select|Wrap|Line Numbers
  1.     rs.Open "Select * From Subject", cn, 1, 1
  2.     list.ListItems.Clear
  3.     While Not rs.EOF
  4.         On Error Resume Next
  5.         With list.ListItems.Add(, , rs!SubjectID, img1, img2)
  6.             .SubItems(1) = rs!Subject
  7.             .SubItems(2) = rs!Units
  8.             '...... and so on...
  9.         End With
  10.         rs.MoveNext
  11.     Wend
  12.  
So what I did was:
Expand|Select|Wrap|Line Numbers
  1.     rs.Open "Select * From Subject", cn, 1, 1
  2.     list.ListItems.Clear
  3.     While Not rs.EOF
  4.         On Error Resume Next
  5.         With list.ListItems.Add(, , rs!SubjectID, img1, img2)
  6.             .SubItems(1) = rs!Subject
  7.             .SubItems(2) = rs!Units & ".0"
  8.             '...... and so on...
  9.         End With
  10.         rs.MoveNext
  11.     Wend
  12.  
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 : (
Nov 28 '07 #1
Share this Question
Share on Google+
3 Replies


Expert 100+
P: 487
Do not use on error resume next until the method bugs and errors fixed. Use
Expand|Select|Wrap|Line Numbers
  1. FormatNumber(unit,2)
Nov 28 '07 #2

lotus18
100+
P: 866
Do not use on error resume next until the method bugs and errors fixed. Use
Expand|Select|Wrap|Line Numbers
  1. FormatNumber(unit,2)
I'm using On Error Resume Next because some of my fields are empty and they are not required to be filled upped. : )

BTW, thanks for your reply : )

Rey Sean
Nov 28 '07 #3

9815402440
100+
P: 180
Hi.
Use the following query to retrieve numbers in the desired format.

select format(intNumber0,"#0.00") as intNumber1 from table

Regards
manpreet singh dhillon hoshiarpur
Nov 28 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.