下面這段代碼,是我用來(lái)計(jì)算每個(gè)月存500元進(jìn)銀行,連續(xù)30年,最后連本帶利能有多少錢(qián)。這里面涉及復(fù)利計(jì)算。界面中右邊的文本框用來(lái)輸出每一次計(jì)算的結(jié)果。
成都創(chuàng)新互聯(lián)公司是一家專注網(wǎng)站建設(shè)、網(wǎng)絡(luò)營(yíng)銷策劃、小程序設(shè)計(jì)、電子商務(wù)建設(shè)、網(wǎng)絡(luò)推廣、移動(dòng)互聯(lián)開(kāi)發(fā)、研究、服務(wù)為一體的技術(shù)型公司。公司成立十余年以來(lái),已經(jīng)為近千家紙箱各業(yè)的企業(yè)公司提供互聯(lián)網(wǎng)服務(wù)。現(xiàn)在,服務(wù)的近千家客戶與我們一路同行,見(jiàn)證我們的成長(zhǎng);未來(lái),我們一起分享成功的喜悅。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
? Dim nianxian As Integer '年限變量
? Dim dingcun As Integer '定存變量
? Dim fuli_big As Long '大復(fù)利
? Dim fuli_small As Long '小復(fù)利
? Dim i As Integer '循環(huán)變量
? Dim DATAstring As String '數(shù)據(jù)字符串
? nianxian = Val(年限_TextBox.Text)
? dingcun = Val(定存_TextBox.Text)
? DATAstring = ""
? For i = 1 To nianxian
? ? ? fuli_small = dingcun * (1 + 0.1875)
? ? ? dingcun = fuli_small
? ? ? fuli_big = fuli_big + fuli_small
? ? ? DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_big) + Chr(13) + Chr(10)
? ? ? 'DATAstring = DATAstring + "[" + Trim(Str(i)) + "]" + Str(fuli_small) + Chr(13) + Chr(10)
? Next
? 'fuli_big = fuli_small
? TextBox1.Text = DATAstring
? 結(jié)果_TextBox.Text = Str(fuli_big) + "元"
End Sub
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
vb.net采用的GDI+實(shí)現(xiàn)圖形繪制,不再使用VB6的Print、Line等語(yǔ)句
'改成這樣試試
Sub?Add(ByVal?a?As?Integer,?ByVal?b?As?Integer)
a=a+1
b+b+1
End?Sub
分享名稱:vb.net代碼事例的簡(jiǎn)單介紹
網(wǎng)站網(wǎng)址:http://vcdvsql.cn/article30/hedeso.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)公司、域名注冊(cè)、網(wǎng)站營(yíng)銷、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)