【VB】简易计算器

学校教了VB语言,作为一个AFO的OIer,我随便写了一个计算器
附工程链接
可执行程序

Private Sub Command1_Click()
    Dim ans As Long
    Dim x As Long
    Dim d As Long
    x = Val(shouxiang.Text): d = Val(gongcha.Text)
    For i = 1 To Val(xiangshu.Text)
        ans = ans + x
        x = x + d
    Next i
    shuchu.Text = Str(ans)
End Sub


Private Sub Command2_Click()
    Dim ans, x, q As Long
    x = Val(shouxiang1.Text): q = Val(gongbi.Text)
    For i = 1 To Val(xiangshu1.Text)
        ans = ans + x
        x = x * q
    Next i
    shuchu1.Text = Str(ans)
End Sub


Private Sub Command3_Click()
    Dim b As Boolean
    Dim x As Long
    x = Val(shuru.Text): b = True
    If x <= 1 Then
        shuchu2.Text = Str(x) + "不是质数"
    Else
        For i = 2 To x - 1
            If x Mod i = 0 Then
                b = False
                Exit For
            End If
        Next i
        If b Then shuchu2.Text = Str(x) + "是质数" Else shuchu2.Text = Str(x) + "不是质数"
    End If
End Sub



你可能感兴趣的:(VB)