Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Vb.net help


  • Please log in to reply

#1
bluntknife

bluntknife

    Member

  • Member
  • PipPip
  • 55 posts
hi am new to VB.net and have been trying to produce a gas bill program but im a bit stuck. im basicly try useing 4 text boxs to gather the require informations, then storeing it into a lstbox rdy for print at a later stage. i can get the information to how you in the list box but i need to be able to times two inputs and display the reult in the list box as a currency, but i am haveing no luck.

[codebox]Public Class Form1
Dim myformat As String = "{0, 10}{1, 18}{2, 16}{3, 18}"

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

lbout.Items.Add(String.Format(myformat, "Customer Num", "Customer Type", "Gas Used", "Cost of Gas"))
End Sub


Private Sub butadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butadd.Click
Dim customernumber, customertype, gasused, unitcost As String
Dim cost As Integer

customernumber = txtnum.Text
customertype = custtype.Text
gasused = txtgas.Text
unitcost = costunit.Text

cost = unitcost * gasused
lbout.Text = cost


lbout.Items.Add(String.Format(myformat, customernumber, customertype, gasused, costunit, cost))


txtnum.Clear()
txtgas.Clear()
custtype.Clear()
costunit.Clear()

End Sub

Private Sub butexit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butexit.Click
Me.Close()
End Sub
End Class
[/codebox]

if oyu need more information or a copy of the program so far just ask

thanks
  • 0

Advertisements


#2
stettybet0

stettybet0

    Trusted Tech

  • Technician
  • 2,579 posts
Alright, multiplying 2 numbers and displaying the result as currency is what we are aiming for, right?

Dim a As Integer
Dim b As Integer
Dim c As Integer 'If you need decimals, use Single instead of Integer.
Dim currency As String
a = 4
b = 6 'These numbers are for example purposes only.
c = a * b
currency = "£" + CStr(c) 'We are using British pounds, right?
ListBox1.Items.Add(currency)

The above code will display £24 in ListBox1. Hopefully you can go from there, and adjust it to fit your needs. If you have any questions, please ask.
  • 0

#3
bluntknife

bluntknife

    Member

  • Topic Starter
  • Member
  • PipPip
  • 55 posts
thanks alot for your help it now works perfectly, stettybet0 you are a person of godly knowledge

many thanks again
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP