直接加1可以用a+=1
創(chuàng)新互聯(lián)建站主營(yíng)新吳網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,app開發(fā)定制,新吳h5成都微信小程序搭建,新吳網(wǎng)站營(yíng)銷推廣歡迎新吳等地區(qū)企業(yè)咨詢
如果是做循環(huán),直接用
For a = 1 To 10
Next
Dim s1!, s2!, a$ '為小數(shù)點(diǎn)的疊加,s1,s2必須定義為單精度型
Dim flag As Boolean 'flag它是過(guò)程及的變量,在通用里必須聲明
'在數(shù)字按鈕控件單擊數(shù)組單擊事件中獲取操作數(shù)(沒(méi)有區(qū)分是哪一個(gè)操作數(shù))
Private Sub Command1_Click(Index As Integer)
x = Text1.Text
If flag = True Or x = "0" Then '查看數(shù)字是否輸入完畢或者是否清零了
Text1.Text = CStr(Index) 'CStr將數(shù)值轉(zhuǎn)換字符
Else
Text1.Text = Text1.Text + CStr(Index) '"+"在這里這個(gè)是對(duì)字符串的操作的疊加,CStr(Index)是接的數(shù)據(jù)
End If
flag = False '時(shí)刻準(zhǔn)備數(shù)字的輸入
End Sub
'2.單擊運(yùn)算符,確定s1,并且要選定運(yùn)算
Private Sub Command2_Click(Index As Integer)
flag = True
s1 = Val(Text1.Text)
Select Case Index
Case 0
a = "+"
Case 1
a = "-"
Case 2
a = "*"
Case 3
a = "/"
End Select
End Sub
'3."="的單擊事件
Private Sub Command3_Click()
flag = True
s2 = Val(Text1.Text)
Select Case a
Case "+"
Text1.Text = s1 + s2
Case "-"
Text1.Text = s1 - s2
Case "*"
Text1.Text = s1 * s2
Case "/"
Text1.Text = s1 / s2 '分母不能為0
End Select
s1 = 0: s2 = 0: a = ""
End Sub
'4.清屏
Private Sub Command4_Click()
Text1.Text = "0"
s1 = 0
s2 = 0
a = ""
flag = False
End Sub
'5.刪除最后輸入的一個(gè)字符,換句話說(shuō),將本文框中的字符串取字符(從左往右取left(string,length)),將最后一個(gè)字符不取就先行
Private Sub Command5_Click()
If Text1.Text = "" Then
Else
Command5.Enabled = True
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
'len求字符串的長(zhǎng)度,left(text1.len(text1)-1減1是取字符串從左往右減去一個(gè)字符串
End If
End Sub
'小數(shù)點(diǎn) 1)顯示出"."(注意前面輸入過(guò)的整數(shù)必須顯示) 2)小數(shù)后能繼續(xù)接受數(shù)字的輸入
Private Sub Command6_Click()
Text1 = Text1 "."
End Sub
'7加入正負(fù)號(hào)--單擊“+、-”,產(chǎn)生一個(gè)"-",而且處于一種等待數(shù)字輸入的一種狀態(tài)
Private Sub Command7_Click()
Dim temp As Double
temp = -Val(Text1.Text)
Text1.Text = temp
If d = " " Then s1 = temp Else s2 = temp
End Sub
Private Sub Command8_Click() '退出
End
End Sub
Private Sub Form_Load() '窗體初始化
Text1.Text = 0
Text1.Locked = True
End Sub
你的代碼中“checkis(0)=obj1 is obj2”的意思是如果obj1和obj2引用的是同一個(gè)對(duì)象,則checkis(0)的返回值為“true”,否則為“false”。下面幾句以此類推。
以下是MSDN中的備注:
Is運(yùn)算符確定兩個(gè)對(duì)象引用是否引用同一個(gè)對(duì)象。但是,它不執(zhí)行值比較。如果 object1 和 object2 引用同一個(gè)對(duì)象實(shí)例,則 result 為 True;如果它們不引用同一個(gè)對(duì)象,則 result 為 False。該運(yùn)算符和TypeOf…Is一樣,也只適用于引用類型。
用法:
Dim i As String = "Hello"
Dim j AS String = "Hello"
Dim k as String = "Hello world"
Console.WriteLine(i Is j) '輸出:True
Console.WriteLine(i Is k) '輸出:False
k = j
Console.WriteLine(i Is k) '輸出:True