Welcome to WebmasterWorld Guest from 34.204.194.190

Forum Moderators: ocean10000

Message Too Old, No Replies

visual basic help

how to make a variable 2 dp

     
4:40 pm on Feb 25, 2009 (gmt 0)

New User

10+ Year Member

joined:Feb 25, 2009
posts: 1
votes: 0


im trying to make a virtual vending machine for my a levels and i have the machine working but all my money values are coming out as normal values and i would like them to be money values such as 1 has to be 1.00

my code so far is:

Private Sub cmdChoice_Click(Index As Integer)
Dim Choiceselect As Integer
Dim Quantity As Byte
Dim cost As Currency

Select Case Index

Case 1
Quantity = InputBox("Please enter the Quantity required", "Quantity")
If Quantity = 0 Then Exit Sub
If Quantity >= 1 <= 50 Then lblOrdered = " Item " & " Quantity " & "Cost " & vbCrLf & vbCrLf & Snackdata(1).Item & " " & Quantity & " " & Snackdata(1).cost & " "
If Quantity >= 51 Then MsgBox ("Invalid order please try again")
lblAmount = "" & Snackdata(1).cost * Quantity

the code for the module is:

Option Explicit

'Virtual Vending Machine Program
'Main Menu form
'Author M Harris
'Date Feb 2009
'Version 1.0

Type SnackChoice

Item As String * 10
Quantity As Byte
cost As Currency
End Type

Public Snackdata(1 To 4) As SnackChoice

Public pointer As Byte

anyone help ?

12:54 pm on Feb 27, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 19, 2006
posts:92
votes: 0


Try:

Public Function SingleToCurrency(sngValue as Single) as String
Return String.Format("&pound;{0}", Math.Round(sngValue, 2))
End Function

(not tested)

2:25 pm on Feb 28, 2009 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Feb 13, 2005
posts:1078
votes: 0


VB has a FormatCurrency function - sounds like what you're looking for.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members