albertc30
Well-known Member
- Joined
- May 7, 2012
- Messages
- 1,091
- Office Version
- 2019
- Platform
- Windows
Hello everybody.
I got this video on youtube and decided to have a go as it seems quite simple.
This will give me an insite how the variables are played about and oerhaps I can understand the logic of all this better.
The code I have seen is in actuall VB express 2010 so I have done my very best to adapt this to VBA excel 2013.
But sadly not all of it works okay.
My code is as follows;
The lines in red are the ones giving me a hard time. I know that the Answer = line is wrong when I have the first two in red as just comments, therefore bypassing them to the next line of code.
Any help as always very much appreciated.
Regards,
Albert
I got this video on youtube and decided to have a go as it seems quite simple.
This will give me an insite how the variables are played about and oerhaps I can understand the logic of all this better.
The code I have seen is in actuall VB express 2010 so I have done my very best to adapt this to VBA excel 2013.
But sadly not all of it works okay.
My code is as follows;
Code:
Private Sub CommandButton1_Click() Dim Celsius As String
Dim Farenheit As String
Dim Answer As String
[COLOR=#ff0000] Celsius = texbox1.Text[/COLOR]
[COLOR=#ff0000] Farenheit = texbox2.Text[/COLOR]
If (TextBox1.Text & TextBox2.Text = vbnullorempty) Then
MsgBox "Please enter a value on either Celsius or Farenheit box.", vbCritical, "Error"
Else
If (TextBox1.Text = vbnullorempty) Then
[COLOR=#ff0000] Answer = Celsius * 9 / 5 + 32[/COLOR]
TextBox2.Text = Int(Answer)
End If
If (TextBox2.Text = vbnullorempty) Then
[COLOR=#ff0000] Answer = (Farenheit - 32) * 5 / 9[/COLOR]
TextBox2.Text = Int(Answer)
End If
End If
End Sub
The lines in red are the ones giving me a hard time. I know that the Answer = line is wrong when I have the first two in red as just comments, therefore bypassing them to the next line of code.
Any help as always very much appreciated.
Regards,
Albert