need help, newbie here - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

need help, newbie here

vhj6vhj6 Posts: 2Member
ok, so I am not sure what I'm doing wrong. I wrote this code for an assignment and it is giving me this error: Conversion from string "" to type 'Double' is not valid...on this line r = CDbl(txtResthr.Text)

Here is the full program:

Public Class Form1

Private Sub txtAge_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtAge.TextChanged

End Sub

Private Sub txtResthr_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtResthr.TextChanged

End Sub

Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
Dim a, r As Double
Dim trainingheartrate As Double
a = CDbl(txtAge.Text)
r = CDbl(txtResthr.Text)
trainingheartrate = 0.7 * (220 - a) + 0.3 * r
trainingheartrate = Math.Round(trainingheartrate, 1)
txtTrainhr.Text = "Your THR is" & trainingheartrate & " beats per minute"
End Sub

Private Sub txtTrainhr_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtTrainhr.TextChanged

End Sub

End Class

Can someone point me in the right direction? Thanks!!

Comments

Sign In or Register to comment.