Im a beginner with programming and im trying to make a simple calculator but i get this error i think i have done all steps right
visual basic help
Started By
xinzx1337
, Jul 26 2015 09:32 AM
#1
Posted 26 July 2015 - 09:32 AM
#1
Posted 26 July 2015 - 09:32 AM
Error 1 Value of type 'Single' cannot be converted to 'System.Windows.Forms.Label'. c:\users\user\documents\visual studio 2010\Projects\WindowsApplication3\WindowsApplication3\Form1.vb 10 23 WindowsApplication3
thanks for help
#3
Posted 26 July 2015 - 09:38 AM
#3
Posted 26 July 2015 - 09:38 AM
Public Class Form1
Dim Num1 As Single
Dim Num2 As Single
Dim Answer As Single
Private Sub Submit_Click(sender As System.Object, e As System.EventArgs) Handles ButtonSubmit.Click
Num1 = TextBoxNum1.Text
Num2 = TextBoxNum2.Text
Answer = Num1 + Num2
LabelAnswer = Answer
End Sub
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Quit.Click
Close()
End Sub
End Class
#5
Posted 26 July 2015 - 12:09 PM
#5
Posted 26 July 2015 - 12:09 PM
Public Class Form1Dim Num1 As SingleDim Num2 As SingleDim Answer As SinglePrivate Sub Submit_Click(sender As System.Object, e As System.EventArgs) Handles ButtonSubmit.ClickNum1 = TextBoxNum1.TextNum2 = TextBoxNum2.TextAnswer = Num1 + Num2LabelAnswer = AnswerEnd SubPrivate Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Quit.ClickClose()End SubEnd Class
TextBoxNum1.Text is a string but you're trying to store it as a single? do you not need to convert it into a single first..
#9
Posted 26 July 2015 - 01:47 PM
Users browsing this thread: