开发者

Calculator for newbs

I'm wor开发者_运维问答king on a calculator in which I want to get some numbers on a circle.

Private Sub Button6_Click(
    ByVal sender As System.Object, 
    ByVal e As System.EventArgs) Handles Button6.Click   

    Dim radius As Integer = TextBox13.Text
    Dim diameter As Integer = TextBox14.Text
    Dim length As Integer = TextBox15.Text
    
    TextBox13.Text = diameter / 2
    TextBox14.Text = radius * 2
    TextBox15.Text = radius * 2 * Math.PI
    TextBox15.Text = diameter * Math.PI
End Sub

That is the current code, but I'm experiencing a problem with "the number must be less than infinity".

Note: I'm a COMPLETE noob.


The error lies in the fact that you tried to assign an integer value of type string. Use the method provided by struct TryParse integer, this will also run in any runtime exception FormatException bran and do not send the application.

Here's an example:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim diameter As Integer = 0
    Dim radius As Integer = 0
    Dim lenght As Integer = 0

    If Integer.TryParse(Me.TextBox13.Text, diameter) Then
        'your code 
    End If

    If Integer.TryParse(Me.TextBox14.Text, radius) Then
        'your code 
    End If

    If Integer.TryParse(Me.TextBox15.Text, lenght) Then
        'your code 
    End If
End Sub

More information about TryParse at this link: http://msdn.microsoft.com/it-it/library/f02979c7.aspx

Bye


See if this works:

   Dim radius As Integer = Integer.Parse(TextBox13.Text)
   Dim diameter As Integer = Integer.Parse(TextBox14.Text)     
   Dim length As Integer = Integer.Parse(TextBox15.Text)   
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜