|
-
Oct 17th, 2004, 09:48 AM
#1
Thread Starter
Member
Cint or Cdbl question
here's the code for the button in question:
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
Dim BattingAverage As Double
BattingAverage = txtHits.Text / txtBat.Text
Dim strAverage As String = "Your Batting Average is " & BattingAverage
lstAverage.Items.Add(strAverage)
End Sub
My teachers instructions says you need to convert your numeric text input to numbers using Cint or Cdbl and I'm not sure this is right. Can anyone help me?
Thank you very much
Last edited by Cassy; Oct 17th, 2004 at 01:44 PM.
-
Oct 17th, 2004, 11:22 AM
#2
Frenzied Member
Re: Cint or Cdbl question
VB Code:
Private Sub btnCompute_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCompute.Click
Dim BattingAverage As Double
BattingAverage = CInt(txtHits.Text)/CInt( txtBat.Text)
Dim strAverage As String = "Your Batting Average is " & BattingAverage
lstAverage.Items.Add(strAverage)
End Sub
Tengo mas preguntas que contestas
-
Oct 17th, 2004, 07:33 PM
#3
PowerPoster
And if you have Option Strict On, then you'll need to convert the double to a string as well:
VB Code:
Dim strAverage As String = "Your Batting Average is " & CStr(BattingAverage)
or:
Dim strAverage As String = "Your Batting Average is " & Convert.ToString(BattingAverage)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|