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

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.