濡備綍鐢╒B缂栬緫璁$畻鍣?- 宸茶В鍐?- 鎼滄悳闂棶
瑕佹眰鏈夆€?鈥?鈥?鈥濃€?鈥濃€渟in鈥濃€渃os鈥濃€渢an鈥濋櫎浜嗕唬鐮佷互澶栵紝鏈€濂借繕鏈夌畝鍗曠殑杩囩▼
瑕佹眰鏈夆€?鈥?鈥?鈥濃€?鈥濃€渟in鈥濃€渃os鈥濃€渢an鈥濋櫎浜嗕唬鐮佷互澶栵紝鏈€濂借繕鏈夌畝鍗曠殑杩囩▼
答案:Dim x!, n1!, n2!
'N1,N2鍒嗗埆浠h〃杈撳叆鐨勭涓€涓暟鍜岀浜屼釜鏁?br>Dim strn1$, strn2$
'StrN1,StrN2鍒嗗埆浠h〃杈撳叆绗竴涓?br>Dim firstN As Boolean
'鍒ゆ柇鏄惁鏄暟瀛楀紑澶?br>Dim pointflag As Boolean
'鍒ゆ柇鏄惁宸叉湁灏忔暟鐐?br>Dim runsign As Integer
'鍙橀噺Runsign鐢ㄦ潵鍌ㄥ瓨杩愮畻绗﹀彿
Dim signflag As Boolean
'鍙橀噺SignFlag鍒ゆ柇鏄惁宸叉湁杩愮畻绗﹀彿
Private Sub form_load()
n1 = 0: n2 = 0
strn1 = "": strn2 = ""
firstN = True
pointflag = False
'灏?PointFlag 璁句负鍚︼紝鍗虫病鏈夊皬鏁扮偣
runsign = 0
signflag = False
'娌℃湁杩愮畻绗﹀彿杈撳叆
End Sub
Private Sub cmdN_Click(Index As Integer)
Select Case Index
'鐢↖ndex 浣滀负鍒ゆ柇鍒嗘敮鐨勬潯浠?br> Case 0 To 9
'濡傛灉Index鏄?鍒?,鍗虫暟瀛?br> If firstNum Then
'杈撳叆涓虹涓€涓暟瀛楃殑璇?br> strn1 = Str(Index)
'瀹炲瀷杞瓧绗﹀瀷
firstN = False
'鍒濊祴鍊兼爣蹇椾负鍋?br> Else
strn1 = strn1 + Str(Index)
'杈撳叆涓嶆槸绗竴涓暟瀛楃殑璇?灏嗚緭鍏ョ殑瀛楃娣诲姞鍒板師鏈夊瓧绗︿覆涓?br> End If '缁撴潫 if 鍧?br> Text1.Text = strn1 '灏嗗瓧绗︿覆缁撴灉鏄剧ず鍒版爣绛句笂
Case 10 '濡傛灉杈撳叆涓哄皬鏁扮偣
If Not pointflag Then '濡傛灉娌℃湁灏忔暟鐐?br> If firstN Then '濡傛灉鏄涓€涓瓧绗?br> strn1 = "0." '鏄剧ず涓?quot; 0." 涓嶅彉
firstN = False
Else
strn1 = strn1 + "."
'鍒濊祴鍊兼爣蹇椾负鍋?鍚﹀垯瀛楃涓蹭笂鍔犱笂灏忔暟鐐圭鍙?br> End If '缁撴潫if鍧?br> Else
Exit Sub
'宸叉湁灏忔暟鐐?鍒欓€€鍑哄崟鍑讳簨浠?涔熷氨鏄鍗曞嚮浜嬩欢涓嶅弽搴?br> End If
pointflag = True
Text1.Text = strn1
'灏嗗皬鏁扮偣鏍囧織涓虹湡,鍗冲湪杈撳叆涓蹭腑鏈変簡灏忔暟鐐?鍦ㄦ樉绀哄睆涓婃樉绀烘暟瀛椾覆
Case 17
If Sgn(Val(strn1)) = 1 Then
strn1 = "-" + strn1
Else
If Sgn(Val(strn1)) = -1 Then
strn1 = Right(strn1, Len(strn1) - 1)
End If
strn1 = "0."
End If
Text1.Text = strn1
Case 12 To 15
firstN = True
'褰撹緭鍏ヤ负杩愮畻绗﹀彿鏃?浣夸笅涓€娆″彲浠ヨ緭鍏ユ柊鏁版嵁
pointflag = False '杩樺師灏忔暟鐐规爣璁板€?br> If signflag Then '鍓嶉潰宸叉湁杩愮畻绗︽湭杩愮畻
Call Run '璋冪敤璁$畻瀛愮▼搴?璇ュ瓙绋嬪簭鍦ㄤ笅闈㈡湁璇存槑
Else
signflag = True
'鍓嶉潰娌℃湁鏈繍绠楃殑,灏嗘湁鏃犺繍绠楃鏍囧織璁句负"鏈?quot;
strn2 = strn1 '鎶婂瓧绗︿覆1澶嶅埗缁欏瓧绗︿覆2
strn1 = "" '瀛楃涓?娓呯┖
End If
runsign = Index - 11
Case 11 '濡傛灉杈撳叆绛夊彿
If Not signflag Then '濡傛灉娌℃湁杈撳叆杩愮畻绗?br> Text1.Text = strn1 '浠ヤ笅鍧囦负閲嶇疆鍚勪釜鍙橀噺
ysjg = Val(strn1)
firstN = True
pointflag = False
Else
Call Run
signflag = False
'濡傛灉宸茶緭鍏ヨ繍绠楃鍦ㄥ唴,璁$畻娓呴櫎鏄惁鏈夎繍绠楃鏍囧織
End If
Case 16
n1 = 0
n2 = 0
'濡傛灉杈撳叆娓呴櫎鎸夐挳,浠ヤ笅鍧囦负閲嶇疆鍚勪釜鍙橀噺,鐩稿綋浜嶧orm_Load涓殑浠g爜
strn1 = ""
strn2 = ""
firstN = True
pointflag = False
runsign = 0
signflag = False
Text1.Text = "0."
End Select
End Sub
Public Sub Run()
Dim ysjg As Single 'Ysjg涓哄眬閮ㄥ彉閲?鐢ㄦ潵瀛樺偍杩愮畻缁撴灉
n1 = Val(strn2) '灏嗗瓧绗︿覆杞崲鎴愭暟鍊?br> n2 = Val(strn1)
Select Case runsign
Case 1
ysjg = n1 + n2
Case 2
ysjg = n1 - n2
Case 3
ysjg = n1 * n2
Case 4
ysjg = n1 / n2
End Select
strn2 = Str(ysjg)
strn1 = strn2
Text1.Text = strn2
End Sub鑱旂郴鎴戯紝鎴戞湁绀轰緥绋嬪簭锛岀瀛﹁绠楀櫒璇翠笅閭鎴戝彂涓粰浣犮€?/p>
涓嶇煡閬撹繖涓槸涓嶆槸鎯宠鐨勩€?/p>
上一个:VB 文件系统 方法
下一个:VB 中的 input函数