d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Visual Basics Question
Add Reply New Topic New Poll
Member
Posts: 3,188
Joined: Jul 27 2014
Gold: Locked
Trader: Scammer
Sep 15 2014 12:46pm
So in my class we're supposed to be writing a click execution that calculates something. However, we've never even learned how to do this ... I believe I introduced the variables right, but it says something along the lines of " Value of type 'Integer' cannot be converted to 'System.Windows.Forms.Label'." Not sure what to do :/

Dims would be introducing integers I believe, MaxInVan should be a constant, wasn't sure how to do that. Then Vans filled would be the input of the attendeesTextbox which I assigned to the varriable attendees. Divided by the MaxInVan, displayed in the vansLabel.
Code
Private Sub calcButton_Click(sender As Object, e As EventArgs) Handles calcButton.Click
' calculates and displays the number of filled vans and the number of people remaining
' declare named constant and variables

Dim attendees As Integer
Dim vans As Integer
Dim remaining As Integer
Dim MaxInVan As Integer
MaxInVan = 10

' store user input in a variable

Integer.TryParse(attendeesTextBox.Text, attendees)

' calculate number of filled vans

vansLabel = attendees \ MaxInVan

End Sub
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 15 2014 07:04pm
the error tells you what's wrong. look at your data types:

vansLabel = attendees \ MaxInVan
label = integer \ integer

you cannot assign an integer into a label. you want something along the lines of:

vansLabel.Text = (attendees \ MaxInVan).ToString()

or whatever casts an integer to a string
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll