6 Replies - 15182 Views - Last Post: 10 February 2006 - 05:52 AM Rate Topic: -----

#1 dippy1  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 29-November 05

decimal points

Posted 02 February 2006 - 08:31 AM

Hello,I am doing a project in vb6 and cannot get the answer to come out in only 2 decimal points i.e. £1.654.67 can anyone help.
Is This A Good Question/Topic? 0
  • +

Replies To: decimal points

#2 dippy1  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 29-November 05

Re: decimal points

Posted 02 February 2006 - 12:21 PM

Here is my code if that helps but my naswer always comes out in to many decimal points
dim earnings(11) As Double
Dim total As Single
Dim highest As Single
Dim lowest As Single
Dim average As Single

Private Sub Command7_Click()


Dim count As Double
'get the values
      For count = 0 To 11
 earnings(count) = InputBox("enter earnings" & count + 1)
        Next count
'Print the Values
    For count = 0 To 11
        Picture1.Print (earnings(count))
    Next count
    End Sub
    
    
    
    Private Sub Command1_Click()
'calculate the total
   Dim count As Single
   For count = 0 To 11
       total = total + earnings(count)
 Next count
 
 'print the total
      Form1.Label1 = total
      End Sub
    Private Sub Command2_Click()
 'print the average
      Form1.Label2 = total / 11
      End Sub
      
      Private Sub Command3_Click()
      Dim count As Single
 'show the highest
   For count = 0 To 11
      If earnings(count) > highest Then
         highest = earnings(count)
      End If
      Next count
     Form1.Label3 = highest
     End Sub
     
Private Sub Command4_Click()
   Dim count As Single
 'show the lowest
 lowest = earnings(0)
  For count = 0 To 11
     If earnings(count) < lowest Then
        lowest = earnings(count)
     End If
     Next count
    Form1.Label4 = lowest
    End Sub
    Private Sub Command5_Click()
  'calculate the tax
     tax = total * 0.15
     Form1.Label5 = tax
  
End Sub


Private Sub Command6_Click()
            
            Form1.Label1 = ""
            Form1.Label2 = ""
            Form1.Label3 = ""
            Form1.Label4 = ""
            Form1.Label4 = ""
            Form1.Label5 = ""
            Text1.Text = ""
            Picture1.Cls
            
            
End Sub



 Private Sub Form_Load()
Text1.Text = InputBox("enter name")
 
 End Sub

Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: decimal points

Posted 02 February 2006 - 07:27 PM

Assuming the variable is named value1, then
value1 = Format(value1,"#0.00")


will do the trick...please note that format function rounds the number...if you are using this for any real world accounting, use the original variable value for further calculations.
Was This Post Helpful? 0
  • +
  • -

#4 sontek  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 8
  • View blog
  • Posts: 283
  • Joined: 13-September 01

Re: decimal points

Posted 05 February 2006 - 11:37 PM

If you're outputting the value you could just .ToString("0.00") to it
Was This Post Helpful? 0
  • +
  • -

#5 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,506
  • Joined: 12-July 02

Re: decimal points

Posted 06 February 2006 - 07:52 AM

Do VB6 objects have a ToString() Method?
Was This Post Helpful? 0
  • +
  • -

#6 dippy1  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 69
  • Joined: 29-November 05

Re: decimal points

Posted 07 February 2006 - 02:26 PM

Got it working perfectly now - until I find another fault that is ,thank you all for your help.
Was This Post Helpful? 0
  • +
  • -

#7 pal121  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 09-February 06

Re: decimal points

Posted 10 February 2006 - 05:52 AM

there are many ways to... i use the format(now()"0,000.00)

not sure if that is correct, but it is something like that!

// edit

Format(8315.4, "£##,##0.00")

but define it as you want to!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1