• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

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