永发信息网

怎样做一个简单的VB计算器

答案:1  悬赏:0  手机版
解决时间 2021-05-18 14:17
我刚学VB想做一个简单的计算器、就是不知道该怎样确定两个变量的值!另外想求一个师父能帮我…
最佳答案
Dim min_len As Integer  txt = txtDisplay.Text  If Left$(txt, 1) = "-" Then    min_len = 2  Else    min_len = 1  End If    If Len(txt) > min_len Then    txtDisplay.Text = Left$(txt, Len(txt) - 1)  Else    txtDisplay.Text = "0"  End IfEnd Sub ' Clear the current entry.Private Sub cmdClearEntry_Click()  txtDisplay.Text = ""End Sub' Add a decimal point to the display.Private Sub cmdDecimal_Click()  If InStr(txtDisplay.Text, ".") Then    Beep  Else    If NewEntry Then      txtDisplay.Text = "."      NewEntry = False    Else      txtDisplay.Text = txtDisplay.Text & "."    End If  End IfEnd Sub ' Calculate the result of the previous operation.Private Sub cmdEquals_Click()Dim new_value As Double  If txtDisplay.Text = "" Then    new_value = 0  Else    new_value = CDbl(txtDisplay.Text)  End If  Select Case Operator    Case opNone      StoredValue = new_value    Case opAdd      StoredValue = StoredValue + new_value    Case opSubtract      StoredValue = StoredValue - new_value    Case opMultiply      StoredValue = StoredValue * new_value    Case opDivide      StoredValue = StoredValue / new_value  End Select  Operator = opNone  NewEntry = True  txtDisplay.Text = Format$(StoredValue)End Sub ' Add a number to the display.Private Sub cmdNumber_Click(Index As Integer)  If NewEntry Then    txtDisplay.Text = Format$(Index)    NewEntry = False  Else    txtDisplay.Text = _      txtDisplay.Text & Format$(Index)  End IfEnd Sub ' Prepare to perform an operation.Private Sub cmdOperator_Click(Index As Integer)  ' Perform the previous operation.  cmdEquals_Click  ' Remember this operation.  Operator = Index  ' Start a new value.  NewEntry = TrueEnd Sub ' Change the value's sign.Private Sub cmdPlusMinus_
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
南京交通职业技术学院的招生电话号码是多少?
琴裳这个名字好听嘛?帮忙测一下字
sin75°等于几分之几?
安陆市孝感男人衣橱(西亚丽宝广场)地址有谁知
谁给我对对联?
远安县宜昌湖北省远安县公安局交通警察大队地
梦幻西游经典版掉线
谁能给我发一些电视剧中经典台词的截图,爱情
汉中北大街房价!
什么叫做生理学
云溪区岳阳流行美我想知道这个在什么地方
补充一则历史上进谏不成功的例子
QQ拼音输入法,怎么样才能知道自己有4级了。
对父母失望看透的句子,形容孩子不听话,父母对
求一种厉害的电脑密码锁软件
推荐资讯
QQT的装备好贵啊
关于空间的设置,每次去装扮,但都保存不了!
林肯公园最近有没有新专辑啊?最近的新专辑是
美国美国的你好怎么说,美国的你好怎么说
现在有没有侠盗猎车3罪恶都市中文补丁
pap3000修理屏幕多少钱啊?
一杯两杯三杯酒 当我们忘掉所有哀愁 来吧兄弟
反恐精英online我进入游戏然后在缩小打开YY再
月经一直来的都不准是怎么回事?
啥毒咋这猛呢 优化+兔子+360+顽固+瑞星+CT 还
灵宝市三门峡九阳授权店地址有谁知道?有点事
海鸣威是哪里人?
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?