vbnet實驗代碼的簡單介紹

vb.net 四則運算代碼

Dim s1!, s2!, a$ '為小數點的疊加,s1,s2必須定義為單精度型

為博羅等地區用戶提供了全套網頁設計制作服務,及博羅網站建設行業解決方案。主營業務為網站制作、成都網站建設、博羅網站設計,以傳統方式定制建設網站,并提供域名空間備案等一條龍服務,秉承以專業、用心的態度為用戶提供真誠的服務。我們深信只要達到每一位用戶的要求,就會得到認可,從而選擇與我們長期合作。這樣,我們也可以走得更遠!

Dim flag As Boolean 'flag它是過程及的變量,在通用里必須聲明

'在數字按鈕控件單擊數組單擊事件中獲取操作數(沒有區分是哪一個操作數)

Private Sub Command1_Click(Index As Integer)

x = Text1.Text

If flag = True Or x = "0" Then '查看數字是否輸入完畢或者是否清零了

Text1.Text = CStr(Index) 'CStr將數值轉換字符

Else

Text1.Text = Text1.Text + CStr(Index) '"+"在這里這個是對字符串的操作的疊加,CStr(Index)是接的數據

End If

flag = False '時刻準備數字的輸入

End Sub

'2.單擊運算符,確定s1,并且要選定運算

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.刪除最后輸入的一個字符,換句話說,將本文框中的字符串取字符(從左往右取left(string,length)),將最后一個字符不取就先行

Private Sub Command5_Click()

If Text1.Text = "" Then

Else

Command5.Enabled = True

Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)

'len求字符串的長度,left(text1.len(text1)-1減1是取字符串從左往右減去一個字符串

End If

End Sub

'小數點 1)顯示出"."(注意前面輸入過的整數必須顯示) 2)小數后能繼續接受數字的輸入

Private Sub Command6_Click()

Text1 = Text1 "."

End Sub

'7加入正負號--單擊“+、-”,產生一個"-",而且處于一種等待數字輸入的一種狀態

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的源代碼,最好說明其解決問題,越多越好,滿意加50分。

下面這段代碼,是我用來計算每個月存500元進銀行,連續30年,最后連本帶利能有多少錢。這里面涉及復利計算。界面中右邊的文本框用來輸出每一次計算的結果。

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 '大復利

? Dim fuli_small As Long '小復利

? Dim i As Integer '循環變量

? Dim DATAstring As String '數據字符串

? 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

? 結果_TextBox.Text = Str(fuli_big) + "元"

End Sub

用vb.net編寫記事本源代碼

Dim sFileName As String

Dim Search

Private Sub dateTimeMenu_Click()

Text1.Text = Now

End Sub

Private Sub deleteMenu_Click()

Text1.Text = Left(Text1.Text, Text1.SelStart) + Mid(Text1.Text, Text1.SelStart + Text1.SelLength + 1)

End Sub

Private Sub findMenu_Click()

Search = InputBox("請輸入要查找的字詞:")

Dim Where1 '獲取需要查找的字符串變量

Text1.SetFocus '文本框獲得焦點,以顯示所找到的內容Search = InputBox("請輸入要查找的字詞:")

Where1 = InStr(Text1.Text, Search) '在文本中查找字符串

If Where1 Then

'若找到則設置選定的起始位置并使找到的字符串高亮

Text1.SelStart = Where1 - 1

Text1.SelLength = Len(Search)

' Me.Caption = Where1 '測試用

'否則給出提示

Else: MsgBox "未找到所要查找的字符串。", vbInformation, "提示"

End If

End Sub

Private Sub findNextMenu_Click()

Dim Where2

Dim StartMe As Integer '查找的起始位置變量

Text1.SetFocus '文本框獲得焦點

StartMe = Text1.SelLength + Text1.SelStart + 1 '給變量賦值

Where2 = InStr(StartMe, Text1.Text, Search) '令其從上次找到的地方找起

If Where2 Then

Text1.SelStart = Where2 - 1

Text1.SelLength = Len(Search)

Else: MsgBox "未找到所要查找的字符串.", vbInformation, "提示"

End If

End Sub

Private Sub aboutMenu_Click()

MsgBox Space(2) "文本編輯器版本號1.0" Chr(13) "由西南財經大學天府學院" Chr(13) Space(5) "肖忠 開發" Chr(13) Space(2) "copyright:天府學院"

End Sub

Private Sub allMenu_Click()

Text1.SelStart = 0

Text1.SelLength = Len(Text1.Text)

End Sub

Private Sub backcolorMenu_Click() '設置背景色代碼

Form1.CommonDialog1.Action = 3

Text1.BackColor = Form1.CommonDialog1.Color

End Sub

Private Sub colorMenu_Click() '改變文字顏色代碼

Form1.CommonDialog1.Action = 3

Text1.ForeColor = Form1.CommonDialog1.Color

End Sub

Private Sub cutMenu_Click()

Clipboard.SetText Text1.SelText

Text1.Text = Left(Text1.Text, Text1.SelStart) + Mid(Text1.Text, Text1.SelStart + Text1.SelLength + 1)

End Sub

Private Sub exitMenu_Click()

End

End Sub

Private Sub fontMenu_Click() '字體菜單代碼

Form1.CommonDialog1.Flags = 3 Or 256

Form1.CommonDialog1.Action = 4

If Len(Form1.CommonDialog1.FontName) = 0 Then

Form1.Text1.FontName = "宋體"

Else

Form1.Text1.FontName = Form1.CommonDialog1.FontName

End If

Form1.Text1.FontSize = Form1.CommonDialog1.FontSize

If Form1.CommonDialog1.FontBold = True Then

Form1.Text1.FontBold = True

Else

Form1.Text1.FontBold = False

End If

If Form1.CommonDialog1.FontItalic = True Then

Form1.Text1.FontItalic = True

Else

Form1.Text1.FontItalic = False

End If

Text1.ForeColor = Form1.CommonDialog1.Color

End Sub

Private Sub Form_Load()

Form1.Text1.Width = Form1.Width - 130

Form1.Text1.Height = Form1.Height

End Sub

Private Sub Form_Resize()

Form1.Text1.Width = Form1.Width - 130

Form1.Text1.Height = Form1.Height

End Sub

Private Sub help1Menu_Click()

Form1.CommonDialog1.HelpCommand = cdlHelpForceFile

Form1.CommonDialog1.HelpFile = "c:\windows\system32\winhelp.hlp"

CommonDialog1.ShowHelp

End Sub

Private Sub newMenu_Click()

If Len(Trim(Text1.Text)) = 0 Then

Form1.Caption = "我的記事本" "--" "未命名"

sFileName = "未命名"

Text1.FontSize = 15

Text1.FontName = "宋體"

Text1.Text = ""

Else

Call saveAsMenu_Click

Form1.Caption = "我的記事本" "--" "未命名"

sFileName = "未命名"

Text1.FontSize = 15

Text1.FontName = "宋體"

Text1.Text = ""

End If

End Sub

Private Sub openMenu_Click() '打開文件代碼

If Len(Trim(Text1.Text)) = 0 Then

Form1.Caption = "我的記事本"

Form1.CommonDialog1.Filter = "文本文件|*.txt"

Form1.CommonDialog1.Flags = 4096

Form1.CommonDialog1.Action = 1

If Len(Form1.CommonDialog1.FileName) 0 Then

sFileName = Form1.CommonDialog1.FileName

Form1.Caption = Form1.Caption "--" Form1.CommonDialog1.FileTitle

Open sFileName For Input As #1

Text1.FontSize = 15

Text1.FontName = "宋體"

Do While Not EOF(1)

Line Input #1, Text$

All$ = All$ + Text$ + Chr(13) + Chr(10)

Loop

Text1.Text = All

Close #1

End If

Else

Call saveAsMenu_Click

Form1.Caption = "我的記事本"

Form1.CommonDialog1.Filter = "文本文件|*.txt"

Form1.CommonDialog1.Flags = 4096

Form1.CommonDialog1.Action = 1

If Len(Form1.CommonDialog1.FileName) 0 Then

sFileName = Form1.CommonDialog1.FileName

Form1.Caption = Form1.Caption "--" Form1.CommonDialog1.FileTitle

Open sFileName For Input As #1

Text1.FontSize = 15

Text1.FontName = "宋體"

Do While Not EOF(1)

Line Input #1, Text$

All$ = All$ + Text$ + Chr(13) + Chr(10)

Loop

Text1.Text = All

Close #1

End If

End If

End Sub

Private Sub pasteMenu_Click() '粘貼菜單代碼

Text1.Text = Left(Text1.Text, Text1.SelStart) + Clipboard.GetText() + Mid(Text1.Text, Text1.SelStart + Text1.SelLength + 1)

End Sub

Private Sub printMenu_Click()

Form1.CommonDialog1.ShowPrinter

For i = 1 To CommonDialog1.Copies

Printer.Print Text1.Text

Printer.Print Text1.Text

Next

Printer.EndDoc

End Sub

Private Sub saveAsMenu_Click() '另存為菜單代碼

If Len(Trim(Text1.Text)) 0 Then

Form1.CommonDialog1.DialogTitle = "保存文件"

Form1.CommonDialog1.InitDir = "D:\"

Form1.CommonDialog1.Filter = "文本文件|*.txt"

Form1.CommonDialog1.Flags = 2

Form1.CommonDialog1.ShowSave

If Len(Form1.CommonDialog1.FileName) 0 Then

sFileName = Form1.CommonDialog1.FileName

Open sFileName For Output As #1

whole$ = Text1.Text

Print #1, whole

Close #1

End If

End If

End Sub

Private Sub saveMenu_Click()

If Len(Trim(Text1.Text)) 0 Then

Form1.CommonDialog1.DialogTitle = "保存文件"

Form1.CommonDialog1.InitDir = "D:\"

Form1.CommonDialog1.FileName = "新建文本"

Form1.CommonDialog1.Filter = "文本文件|*.txt"

Form1.CommonDialog1.Flags = 2

Form1.CommonDialog1.ShowSave

If Len(Form1.CommonDialog1.FileName) 0 Then

sFileName = Form1.CommonDialog1.FileName

Open sFileName For Output As #1

whole$ = Text1.Text

Print #1, whole

Close #1

End If

End If

End Sub

Private Sub statusMenu_Click()

End Sub

網站題目:vbnet實驗代碼的簡單介紹
URL分享:http://m.kartarina.com/article8/hddpop.html

成都網站建設公司_創新互聯,為您提供標簽優化響應式網站網站營銷網站導航企業網站制作外貿網站建設

廣告

聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯

搜索引擎優化
主站蜘蛛池模板: 亚洲日韩v无码中文字幕| 曰产无码久久久久久精品| 曰韩无码无遮挡A级毛片| av无码久久久久不卡免费网站| 亚洲AV无码国产在丝袜线观看| 无码人妻精品一区二区三18禁| 亚洲AV无码精品国产成人| 无码色AV一二区在线播放| 亚洲国产成人无码av在线播放| 激情射精爆插热吻无码视频| 超清无码无卡中文字幕| 国产精品无码亚洲精品2021| 无码AV中文一区二区三区| 东京热av人妻无码专区| 在线精品免费视频无码的| 精品多人p群无码| 无码一区二区三区在线观看 | 亚洲人片在线观看天堂无码| 亚洲精品无码永久在线观看男男 | 惠民福利中文字幕人妻无码乱精品 | 无码八A片人妻少妇久久| 人妻aⅴ中文字幕无码| 无码乱肉视频免费大全合集| 亚洲中文字幕无码日韩| 人妻丝袜无码专区视频网站| 无码国产精品久久一区免费 | 国产成人无码a区在线观看视频免费| 国产成人无码久久久精品一| 67194成是人免费无码| 台湾无码AV一区二区三区| 色欲AV无码一区二区三区| 在线精品免费视频无码的| 国产乱子伦精品无码专区| 亚洲精品无码专区在线在线播放| 亚洲乱亚洲乱妇无码麻豆| 日韩精品无码熟人妻视频| 亚洲欧洲av综合色无码| 自拍中文精品无码| 亚洲日韩国产二区无码| 亚洲av中文无码| 日本精品无码一区二区三区久久久|