basic vb.net question

FRAGMAN BOB

Limp Gawd
Joined
Jan 25, 2005
Messages
292
hey guys, I've got a beginner vb.net class this semester and looking for some help with one line in my program.

"Private Sub btnDispBill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDispBill.Click
'declare variables'
Dim cust As String
Dim hours As Single
Dim cost As Single
Dim total As Single

'define variables'
cust = txtCust.Text
hours = txtHours.Text
cost = txtCost.Text


'calculate total cost'
total = (hours * 35) + cost

'display customer information and total bill'
lstTotal.Items.Clear()
lstTotal.Items.Add("Customer " & (Format(cust, "name")))
lstTotal.Items.Add("Labor Cost " & (Format(hours * 35, "currency")))
lstTotal.Items.Add("Parts Cost " & (Format(cost, "currency")))
lstTotal.Items.Add("Total Cost " & (Format(total, "currency")))
End Sub"

The underlined line is where I have trouble. What is the method to display the variable "cust" (string) from the textbox input into a listbox? The singles work just fine, but the string gives me an error. Apparently the items.add method is only for int's. Thanks guys
 
ListBox.Add() accepts ListItem objects.
Code:
lstTotal.Items.Add(New ListItem("Customer" & (Format(cust, "name"))))
 
Back
Top