如题所述
ç¨vb6.0
设置1个Labelï¼16个CommandButtonï¼å åä¹é¤è®¾ç½®ä¸ºä¸ä¸ªæ§ä»¶æ°ç»Command1ï¼ï¼è®¾ç½®ä¸ºä¸ä¸ªæ§ä»¶æ°ç»Command2ï¼0ï½9å°å°æ°ç¹è®¾ç½®æä¸ä¸ªæ§ä»¶æ°ç»Command3ï¼åèªçIndexå±æ§å¼ä¸å¯¹åºçæ°å¼ç¸åï¼å°æ°ç¹ä¸º10ï¼æ ç¾çCaption设为空ï¼16个CommandButtonæç §çé¢å±æ§è®¾ç½®Caption
代ç æ¯ï¼
Dim s(1) As String 'åæ¾äºä¸ªæä½æ°
Dim op, k As Integer 'opåæ¾æä½ç¬¦å¯¹åºç´¢å¼å¼,k对åºæä½æ°ä¸æ
Dim b As Boolean 'æ§å¶æ¾ç¤ºæ ç¾çæ é¢çåå¼æ¯å¦ä¸ºç©º
'ä¸è¿°åéå为çªä½çº§åéï¼å¯ä»¥è¢«ä»¥ä¸å个è¿ç¨ä½¿ç¨
Private Sub Command1_Click(Index As Integer) 'ç¹å»è¿ç®ç¬¦
k = 1 'åå¤åæ¾æ¯äºä¸ªæä½æ°
op = Index 'ç¡®å®æäºåªä¸ªè¿ç®ç¬¦
Command2.Enabled = True '=æé®ææ
b = True 'æ ç¾ä¸åå¤æ¾ç¤ºå¦ä¸æä½æ°
End Sub
Private Sub Command2_Click() 'æäº=æé®åæ§è¡ç代ç
Select Case op 'å°æ°å串转æ¢æå精度æ°æ®åè¿è¡è®¡ç®
Case 0: Label1.Caption = Str(CSng(s(0)) + CSng(s(1)))
Case 1: Label1.Caption = Str(CSng(s(0)) - CSng(s(1)))
Case 2: Label1.Caption = Str(CSng(s(0)) * CSng(s(1)))
Case 3: Label1.Caption = Str(CSng(s(0)) / CSng(s(1)))
End Select
s(0) = "": s(1) = ""
b = True 'æ ç¾ä¸åå¤æ¾ç¤ºè¿ç®ç»æ
k = 0 'æä½æ°åä»å¤´å¼å§
For i = 0 To 3
Command1(i).Enabled = False 'åè¿ç®ç¬¦æé®åç°
Next i
Command2.Enabled = False '=æé®åç°
End Sub
Private Sub Command3_Click(Index As Integer) 'æäºæ°åæé®åå°æ°ç¹æé®æ§è¡ç代ç
For i = 0 To 3 'è¿ç®ç¬¦æé®ææ
Command1(i).Enabled = True
Next i
If b Then Label1.Caption = "" '表示æ¯å¦ä¸æä½æ°
If Index = 10 Then 'è¥æ¯å°æ°ç¹
Label1.Caption = Label1.Caption + "."
Else
Label1.Caption = Label1.Caption + Chr(48 + Index)
End If
s(k) = Label1.Caption 'åæ¾æä½æ°
b = False 'åä¸ä¸ªæä½æ°
End Sub
Private Sub Form_Load()
For i = 0 To 3 'åå§æ¶è¿ç®ç¬¦æé®ç°è²
Command1(i).Enabled = False
Next i
Command2.Enabled = False 'åå§æ¶=æé®ç°è²
s(0) = ""
s(1) = ""
k = 0
End Sub
设置1个Labelï¼16个CommandButtonï¼å åä¹é¤è®¾ç½®ä¸ºä¸ä¸ªæ§ä»¶æ°ç»Command1ï¼ï¼è®¾ç½®ä¸ºä¸ä¸ªæ§ä»¶æ°ç»Command2ï¼0ï½9å°å°æ°ç¹è®¾ç½®æä¸ä¸ªæ§ä»¶æ°ç»Command3ï¼åèªçIndexå±æ§å¼ä¸å¯¹åºçæ°å¼ç¸åï¼å°æ°ç¹ä¸º10ï¼æ ç¾çCaption设为空ï¼16个CommandButtonæç §çé¢å±æ§è®¾ç½®Caption
代ç æ¯ï¼
Dim s(1) As String 'åæ¾äºä¸ªæä½æ°
Dim op, k As Integer 'opåæ¾æä½ç¬¦å¯¹åºç´¢å¼å¼,k对åºæä½æ°ä¸æ
Dim b As Boolean 'æ§å¶æ¾ç¤ºæ ç¾çæ é¢çåå¼æ¯å¦ä¸ºç©º
'ä¸è¿°åéå为çªä½çº§åéï¼å¯ä»¥è¢«ä»¥ä¸å个è¿ç¨ä½¿ç¨
Private Sub Command1_Click(Index As Integer) 'ç¹å»è¿ç®ç¬¦
k = 1 'åå¤åæ¾æ¯äºä¸ªæä½æ°
op = Index 'ç¡®å®æäºåªä¸ªè¿ç®ç¬¦
Command2.Enabled = True '=æé®ææ
b = True 'æ ç¾ä¸åå¤æ¾ç¤ºå¦ä¸æä½æ°
End Sub
Private Sub Command2_Click() 'æäº=æé®åæ§è¡ç代ç
Select Case op 'å°æ°å串转æ¢æå精度æ°æ®åè¿è¡è®¡ç®
Case 0: Label1.Caption = Str(CSng(s(0)) + CSng(s(1)))
Case 1: Label1.Caption = Str(CSng(s(0)) - CSng(s(1)))
Case 2: Label1.Caption = Str(CSng(s(0)) * CSng(s(1)))
Case 3: Label1.Caption = Str(CSng(s(0)) / CSng(s(1)))
End Select
s(0) = "": s(1) = ""
b = True 'æ ç¾ä¸åå¤æ¾ç¤ºè¿ç®ç»æ
k = 0 'æä½æ°åä»å¤´å¼å§
For i = 0 To 3
Command1(i).Enabled = False 'åè¿ç®ç¬¦æé®åç°
Next i
Command2.Enabled = False '=æé®åç°
End Sub
Private Sub Command3_Click(Index As Integer) 'æäºæ°åæé®åå°æ°ç¹æé®æ§è¡ç代ç
For i = 0 To 3 'è¿ç®ç¬¦æé®ææ
Command1(i).Enabled = True
Next i
If b Then Label1.Caption = "" '表示æ¯å¦ä¸æä½æ°
If Index = 10 Then 'è¥æ¯å°æ°ç¹
Label1.Caption = Label1.Caption + "."
Else
Label1.Caption = Label1.Caption + Chr(48 + Index)
End If
s(k) = Label1.Caption 'åæ¾æä½æ°
b = False 'åä¸ä¸ªæä½æ°
End Sub
Private Sub Form_Load()
For i = 0 To 3 'åå§æ¶è¿ç®ç¬¦æé®ç°è²
Command1(i).Enabled = False
Next i
Command2.Enabled = False 'åå§æ¶=æé®ç°è²
s(0) = ""
s(1) = ""
k = 0
End Sub
温馨提示:答案为网友推荐,仅供参考
第1个回答 2007-01-07
靠 代码 我记得至少600多行!能整上来吗?