版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、A5 Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Click TextBox1.Text = Val(TextBox1.Text) + 1End SubB1 Module Module1Sub Main() Dim a As Boolean Dim b As Boolean a = True b = False Console.WriteLine("0 1 2 3", "a", True, "b", Fa
2、lse) Console.WriteLine("0 1 2 3 4", a, "AND", b, "為a", a And b) Console.WriteLine("0 1 2 3 4 5", a, "AND", "Not", b, "為a", a And Not b) Console.WriteLine("0 1 2 3 4 5 6 ", a, ">", b, "OR", b, "
3、;為a", a > b Or b) Console.ReadLine()End SubEnd ModuleB2 Module Module2 Sub main() Dim x As Integer Dim y As Integer Console.Write("Input x =") x = Console.ReadLine Console.Write("Input y =") y = Console.ReadLine Console.WriteLine("0 1", "表達(dá)式1的結(jié)果為", Mat
4、h.Sin(x) + Math.Cos(y) Console.WriteLine("0 1", "表達(dá)式2的結(jié)果為", (x 2 + y 2) / Math.Abs(y) (1 / 3) Console.WriteLine("0 1", "表達(dá)式3的結(jié)果為", x + y > x 2 - 10 * x) Console.ReadLine()End SubEnd ModuleB3 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e A
5、s System.EventArgs) Handles Button1.Click TextBox1.Text = Int(Rnd() * 100 + -49) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = Int(Rnd() * 9998 + 1) * 0.01End SubB4 Randomize() Label1.Text = Int(Rnd() * 9000 + 1000
6、) Dim a, b, c, d As Integer a = Label1.Text 1000 b = (Label1.Text Mod 1000) 100 c = (Label1.Text Mod (a * 1000 + b * 100) 10 d = (Label1.Text Mod 10) Label2.Text = c * 1000 + a * 100 + d * 10 + bB5 Dim a As Double a = TextBox1.Text Label1.Text = Format(a, "#,#.0000") Label2.Text = aB10 Tex
7、tBox1.Text = UCase(TextBox1.Text) TextBox1.SelectionStart = Len(TextBox1.Text)B6 Dim a = TextBox1.Text Label1.Text = Microsoft.VisualBasic.Left(a, 16) Label2.Text = Mid(a, 17, 6) Label3.Text = Microsoft.VisualBasic.Right(a, 5)B7 Dim a, b As String a = TextBox1.Text b = TextBox2.Text Label1.Text = Re
8、place(a, b, "")B8 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim F = Val(TextBox1.Text), C = Val(TextBox2.Text) C = (5 / 9) * (F - 32) TextBox1.Text = Math.Round(C, 2) End Sub Private Sub Button2_Click(ByVal sender As System.
9、Object, ByVal e As System.EventArgs) Handles Button2.Click Dim F = Val(TextBox1.Text), C = Val(TextBox2.Text) F = (9 / 5) * C + 32 TextBox2.Text = Math.Round(F, 2)End SubB9 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim p = 3.14, a = V
10、al(TextBox1.Text) TextBox2.Text = Format(p * a * a, "#.00") End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim p = 3.14, a = Val(TextBox1.Text) TextBox3.Text = Format(2 * p * a, "#.00") End Sub Private Sub TextB
11、ox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress If e.KeyChar = Chr(13) Then If IsNumeric(TextBox1.Text) = False Then MsgBox("輸入非法字符,請(qǐng)重新輸入", 0, "友情提示") TextBox1.Text = "" TextBox1.Focus() End If End IfEnd
12、SubC1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim p = 3.14, a = Val(TextBox1.Text), b = Val(TextBox2.Text) TextBox2.Text = 2 * p * a TextBox3.Text = p * a * a If IsNumeric(TextBox1.Text) = False Then MsgBox("輸入值不合法") End I
13、fEnd SubC2 Dim x, y As Single x = InputBox("輸入x=") If x > 20 Then y = x 2 + 3 * x + 2 MsgBox("結(jié)果為" & y) ElseIf x < 10 Then y = 0.5 + Math.Abs(x) MsgBox("結(jié)果為" & y) Else y = (3 * x) 0.5 - 2 MsgBox("結(jié)果為" & y) End If或者 Dim x, y As Single x = Val(
14、TextBox1.Text) Select Case x Case Is < 10 y = 0.5 + Math.Abs(x) MsgBox("結(jié)果為" & y) Case Is > 20 y = x 2 + 3 * x + 2 MsgBox("結(jié)果為" & y) Case Else y = (3 * x) 0.5 - 2 MsgBox("結(jié)果為" & y) End SelectC3 Dim a, b, c As Single a = InputBox("輸入a:") b = I
15、nputBox("輸入b:") c = InputBox("輸入c:") If a + b > c And b + c > a And a + c > b Then If a = b And b = c Then MsgBox("等邊") If a 2 + b 2 = c 2 Or a 2 + c 2 = b 2 Or b 2 + c 2 = a 2 Then MsgBox("直角") If (a = b Xor b = c) Or (a = c Xor a = b) Then MsgBox(&q
16、uot;等腰") End IfEnd SubC4 Dim a, b, c As Integer Randomize() Label1.Text = Int(Rnd() * (900) + 100) a = Label1.Text 100 Label2.Text = a b = (Label1.Text Mod 100) 10 Label3.Text = b c = Label1.Text Mod 10 Label4.Text = cEnd SubC5 Dim a, b, c As Integer Randomize() a = Int(Rnd() * 90 + 10) b = Int
17、(Rnd() * 90 + 10) c = Int(Rnd() * 4 + 0) Select Case c Case 0 Label1.Text = a + b Case 1 Label1.Text = a * b Case 2 Label1.Text = a / b Case 3 Label1.Text = a - bEnd SelectC6 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, b As Singl
18、e a = TextBox1.Text If a > 5000 Then Label5.Text = "八折" : Label6.Text = a * 0.8 ElseIf a > 3000 Then Label5.Text = "八五折" : Label6.Text = a * 0.85 ElseIf a > 2000 Then Label5.Text = "九折" : Label6.Text = a * 0.9 ElseIf a > 1000 Then Label5.Text = "九五折&quo
19、t; : Label6.Text = a * 0.95 Else Label5.Text = "原價(jià)" : Label6.Text = a End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click TextBox1.Text = "" Label5.Text = "" Label6.Text = ""End SubC7 Dim x
20、, y, z, t x = Val(InputBox("輸入x") y = Val(InputBox("輸入y") z = Val(InputBox("輸入z")Label4.Text = x : Label5.Text = y : Label6.Text = zIf x < y Then t = x : x = y : y = t If z > x Then t = y : y = x : x = z : z = t ElseIf z > y Then t = y : y = z : z = t End If En
21、d If If x > y Then If z > x Then t = x : x = z : z = y : y = x ElseIf z > y Then t = y : y = z : z = tEnd IfEnd If Label9.Text = x : Label10.Text = y : Label11.Text = z End Sub C8 Dim a, b, c As Double a = TextBox1.Text : b = TextBox2.Text : c = TextBox3.Text If b 2 - 4 * a * c < 0 Then
22、TextBox4.Text = "無解" : TextBox5.Text = "無解" ElseIf b 2 - 4 * a * c = 0 Then TextBox4.Text = (-b + Math.Sqrt(b 2 - 4 * a * c) / 2 TextBox5.Text = (-b + Math.Sqrt(b 2 - 4 * a * c) / 2 Else TextBox4.Text = (-b + Math.Sqrt(b 2 - 4 * a * c) / 2 TextBox5.Text = (-b - Math.Sqrt(b 2 - 4
23、* a * c) / 2 End IfD1 Dim a, b, x Randomize() For i = 1 To 100 x = 0.01 * Int(Rnd() * 99 + 1) If x < 0.5 Then a = a + 1 ElseIf x >= 0.5 Then b = b + 1 End If Next TextBox1.Text = "正面" & a & "%" & "反面" & b & "%" End SubD2 Dim a, b, i F
24、or i = 2 To 100For a = 2 To i - 1 If i Mod a = 0 Then Exit For End IfNext If a > i - 1 Then b = b & String.Format(Str(i) End IfNextLabel1.Text = bD3 If TextBox1.Text = "111" And TextBox2.Text = "111" Then MsgBox("登錄成功!", 0, "提示信息") Else MsgBox("登錄失
25、?。?quot;, 0, "提示信息") TextBox1.Text = "" TextBox2.Text = "" TextBox1.Focus() n = n + 1 If n >= 3 Then MsgBox("3次登錄失??!", 0, "提示信息") : End End IfD4 Dim m%, n%, x%, y%, f% m = Val(TextBox1.Text) n = Val(TextBox2.Text) If n Mod 2 <> 0 Then MsgBox
26、("腳數(shù)必須為偶數(shù),請(qǐng)重新輸入") End If For i = 0 To m f = m - i If n = 2 * i + 4 * f Then x = i y = f Exit For End If Next TextBox3.Text = x TextBox4.Text = y If x < 0 Or y < 0 Then MsgBox("數(shù)據(jù)錯(cuò)誤") End If D5 Dim n As Integer, m As Single n = Val(TextBox1.Text) m = 2 For i = 1 To n m = m *
27、 (2 * i) 2 / (2 * i - 1) * (2 * i + 1) Next TextBox2.Text = m End SubD6 秋水仙花數(shù)Dim a, b, c, d, n For n = 100 To 999 a = n 100 b = (n Mod 100) 10 c = n Mod 10 If n = a 3 + b 3 + c 3 Then d = d & String.Format(Str(n) Label1.Text = d End If NextD7 Dim i As Integer = 1, a, sum As Double a = 1 sum = 1
28、Do a = 1 / (1 / a) + i) sum = sum + a i = i + 1 Loop Until a < 10 (-4) MsgBox(sum)D8 金字塔Dim i, j As Integer, s, a As String s = "" For i = 1 To 9 s = s + Space(9 - i) a = i For j = 1 To 2 * i - 1 s = s + a Next j s = s + vbCrLf Next i Label1.Text = s End SubD9 迭代法求立方根Dim x1#, x0#, t#, a
29、#, i# For i = 3 To 27 x0 = i a = x0 Do x1 = (2 / 3) * x0 + (a / (3 * x0 * x0) t = x0 x0 = x1 Loop Until Math.Abs(x0 - t) < 10 (-5)If i = 3 Then TextBox1.Text = x1 If i = 27 Then TextBox3.Text = x1Next TextBox2.Text = 3 (1 / 3) TextBox4.Text = 27 (1 / 3) D10 Dim i, j As Integer, m, n, a As Single
30、For i = 1 To 30 m = m + 10000 Next a = 0.01 For j = 1 To 30 n = n + a a = a * 2 Next Label1.Text = Format(m, "#,#.00") Label2.Text = Format(n, "#,#.00") 數(shù)組E1 Dim a, b, n a = Val(TextBox1.Text) b = Val(TextBox2.Text) n = Val(TextBox3.Text) If a Mod 1 <> 0 Then TextBox1.Focus
31、() MsgBox("輸入整數(shù)!") End If If b Mod 1 <> 0 Then TextBox2.Focus() MsgBox("輸入整數(shù)!") End If If n Mod 4 <> 0 Then TextBox3.Focus() MsgBox("輸入n為4的倍數(shù)!") End If '以上為數(shù)據(jù)準(zhǔn)備 Dim c(0 To n - 1), i, s For i = 0 To n - 1 Randomize() c(i) = Int(Rnd() * (b - a + 1) + a) s
32、= s + Str(c(i) + "" If (i + 1) Mod 4 = 0 Then s = s + vbCrLf End If Next MsgBox(s) '以上為準(zhǔn)備隨機(jī)數(shù) Dim max = c(0), min = c(0) For i = 0 To n - 1 If c(i) > max Then max = c(i) If c(i) < min Then min = c(i) Next '以上為求最大值最小值 MsgBox("最大值為" & max & " 最小值為" &a
33、mp; min) Dim ave, sum For i = 0 To n - 1 sum = sum + c(i) Next ave = sum / n '以上為求平均值 MsgBox("平均值為" & ave) E2 Module Module1 Sub Main() Dim arrA(99), arrB(127), a, x, z, i As Integer, y, b As String b = 0 Randomize() For i = 0 To 99 arrA(i) = Int(Rnd() * 128) Next For j = 0 To 99 F
34、or m = 0 To 127 If arrA(j) = m Then arrB(m) = arrB(m) + 1 End If Next Next For a = 48 To 57 b = Chr(a) If arrB(a) <> 0 Then Console.WriteLine(b & ":" & arrB(a) End If Next For x = 65 To 90 y = Chr(x) & Chr(x + 32) z = x + 1 If arrB(x) + arrB(x + 32) <> 0 Then Consol
35、e.WriteLine(y & ":" & Val(arrB(x) + arrB(z) End If Next Console.ReadLine()End SubEnd Module E4 Dim A(19), B(25), max, c As Integer, s As String Randomize() For i = 0 To 19 A(i) = Int(Rnd() * 26 + 65) For j = 65 To 90 If A(i) = j Then B(j - 65) = B(j - 65) + 1 End If Next Next max =
36、 B(0) For m = 0 To 25 If B(m) = 0 Then s = s + "" + Chr(m + 65) If B(m) > max Then max = B(m) : c = m Next Label2.Text = Chr(c + 65) & " " & max Label4.Text = s End SubE6 Public Class e6 Dim a%(8) Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.
37、Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress Static num%, i If e.KeyChar = Chr(13) Then If num > 8 Then TextBox1.Text = "" Exit Sub End If a(num) = Val(TextBox1.Text) num = num + 1 TextBox1.SelectionStart = 0 TextBox1.SelectionLength = Len(TextBox1.Text) End If Dim s$ s =
38、a(1) For i = 1 To 8 s = s & "," & a(i) Label2.Text = s Next End Sub Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim i%, j%, t%, k%, x$ i = 1 Do Until i > 8 j = 0 Do Until j > i - 1 If a(i) > a(j) Then Exit Do Else j
39、= j + 1 End If Loop t = a(i) : k = i - 1 Do While k > j - 1 a(k + 1) = a(k) k = k - 1 Loop a(k + 1) = t i = i + 1 Loop x = a(1) For i = 1 To 8 x = x & "," & a(i) Next Label4.Text = x End SubEnd Class F1 Dim a%() Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
40、 System.EventArgs) Handles Button1.Click MsgBox(f1(a) End Sub Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load a = 8, 7, 6, 3, 2, 9 End Sub Function f1%(ByVal b%() Dim i% f1 = b(0) For i = 1 To b.GetUpperBound(0) If f1 > b(i) Then f1 = b(i) Ne
41、xt End Function Sub s1(ByVal c%(), ByRef min%) Dim i% min = c(0) For i = 1 To c.GetUpperBound(0) If min > c(i) Then min = c(i) Next End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim y% s1(a, y) MsgBox(y)End SubF3 Private Sub Te
42、xtBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress Dim x If TextBox1.Text <> "" Then x = Val(TextBox1.Text) TextBox2.Text = (x / 180) * 3.14 * 10 TextBox3.Text = "" : TextBox4.Text = "" End If End S
43、ub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim x# x = Val(TextBox1.Text) * 3.14 / 180 swap(x) End Sub Sub swap(ByVal x) Dim y#, y0#, n# Dim j = Val(TextBox5.Text) If j <= 0 Then MsgBox("輸入合法精度>=0") : End Do y0 = y n
44、= n + 1 y = y + (-1) (n - 1) * x (2 * n - 1) / jc(2 * n - 1) Loop Until Math.Abs(y - y0) < jTextBox3.Text = y End Sub Function jc(ByVal n) jc = 1 Dim i# For i = 1 To n jc = jc * i Next End Function Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim a a = Val(TextBox1.Text) * 3.14 / 180 TextBox4.Text = Math.Sin(a) End SubF7 Dim m%, l1%, l2%, c$ Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年電力供應(yīng)服務(wù)詳細(xì)合同版B版
- 2024年運(yùn)輸服務(wù)司機(jī)協(xié)議規(guī)定細(xì)則版B版
- 石油化工設(shè)備維護(hù)合同
- 2024某制造業(yè)公司與某物流公司之間關(guān)于國際物流服務(wù)的合同
- 2025年度環(huán)境污染治理與生態(tài)保護(hù)協(xié)議3篇
- 2024年比亞迪公司全職員工勞動(dòng)協(xié)議樣本版B版
- 樣品買賣的合同
- 二零二五年專業(yè)考察包車服務(wù)協(xié)議2篇
- 2024版地基承包合同
- 二年級(jí)數(shù)學(xué)計(jì)算題專項(xiàng)練習(xí)集錦
- 采購部績效考核
- 超短波操作流程圖
- 小學(xué)2022 年國家義務(wù)教育質(zhì)量監(jiān)測工作方案
- 化學(xué)品安全技術(shù)說明(膠水)
- 南寧市中小學(xué)學(xué)籍管理系統(tǒng)數(shù)據(jù)采集表
- 中空吹塑成型課件
- 領(lǐng)先閱讀X計(jì)劃第四級(jí)Bug Hunt 教學(xué)設(shè)計(jì)
- 《詩詞格律》word版
- 預(yù)算第二十三講
- 高中體育與健康人教版全一冊(cè) 6.2田徑—短跑 課件(共11張PPT)
- 蔬菜供貨服務(wù)保障方案
評(píng)論
0/150
提交評(píng)論