Share via

Declaration Expected?

Chukwuemeka Ihenacho 1 Reputation point
2022-03-21T03:16:11.763+00:00

Public Class Form1

Dim Cels As Integer
Cels = TempValue.Text
Dim Conversion As Integer = Val(TempValue.Text) * 5556 - 32
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

End Sub

Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click
    MsgBox("Your temperature in Celsius is " & Conversion)
End Sub

End Class

Developer technologies | VB

1 answer

Sort by: Most helpful
  1. Viorel 127K Reputation points
    2022-03-21T13:47:16.233+00:00

    Try moving the first three lines to your function:

    Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click
       Dim Cels As Integer
       Cels = TempValue.Text
       Dim Conversion As Integer = Val(TempValue.Text) * 5556 - 32
       MsgBox("Your temperature in Celsius is " & Conversion)
    End Sub
    

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.