VB基础入门教程最后一课,书籍推荐,配套程序和代码的发布-VB教程021
视频教程链接:
bilibili:https://space.bilibili.com/54144454/#/channel/detail?cid=43133
腾讯视频:http://v.qq.com/vplus/0ae681297cf332c34037313facdf59e3/videos
配套程序链接:
链接: https://pan.baidu.com/s/1jxpdolTI93zJIwIfXH3qPA 密码: xbrn
配套程序源代码链接:
链接: https://pan.baidu.com/s/1B2IVCYioF01xFTBoaz2V1A 密码: uy4r
书籍:
链接: https://pan.baidu.com/s/1RGcu98iNBwQ1yT9Uw5mGNg 密码: agba
配套程序源代码:
1.乘法口诀表
Dim i, j As Integer
Dim s As String
Text1.Text = ""
For i = 1 To 9
For j = 1 To i
s = Str(i) + "X" + Str(j) + "=" + Str(i * j)
Text1.Text = Text1.Text + s
Next j
Text1.Text = Text1.Text + vbCrLf
Next i
2.枚举算法
List1.Clear
Dim x, y, c As Integer
For x = 0 To 240
For y = 0 To 100
If 5 * x + 12 * y = 1200 Then
List1.AddItem Str(x) + " " + Str(y)
c = c + 1
End If
Next y
Next x
Text1.Text = Str(c)
3.解析算法
Text2.Text = ""
Dim x, y As Double
x = Val(Text1.Text)
Do While x > 0
y = x Mod 2
x = x \ 2
Text2.Text = Str(y) + Text2.Text
Loop
4.冒泡排序
List2.Clear
n = 5
For i = 1 To n - 1
For j = n To i + 1 Step -1
If a(j)
t = a(j): a(j) = a(j - 1): a(j - 1) = t
End If
Next j
Next i
For y = 1 To 5
List2.AddItem Str(a(y))
Next y
5.选择排序
List2.Clear
n = 5
For i = 1 To n - 1
k = i
For j = i + 1 To n
If a(k) > a(j) Then k = j
Next j
If k i Then
t = a(k): a(k) = a(i): a(i) = t
End If
Next i
For y = 1 To 5
List2.AddItem Str(a(y))
Next y
6.顺序查找
Dim n, Key As Integer
Dim f As Boolean
f = False
n = 5
Key = Val(Text1.Text)
For i = 1 To n
If a(i) = Key Then
Label1.Caption = Str(a(i)) + "已找到"
f = True
Exit For
End If
Next i
If f = False Then Label1.Caption = "查无此数"
7.对分查找
Dim Key As Integer
Dim f As Boolean
f = False
i = 1
j = 5
Key = Val(Text1.Text)
Do While i
m = Fix((i + j) / 2)
If a(m) = Key Then
Label1.Caption = Str(a(m)) + "已找到"
f = True
Exit Do
End If
If Key
j = m - 1
Else
i = m + 1
End If
Loop
If f = False Then Label1.Caption = "查无此数"
8.递归算法
Function dg(w As Integer) As Long
If w
dg = 1
Else
dg = w * dg(w - 1)
End If
End Function
Private Sub Command5_Click()
Dim s As Long
s = dg(Val(Text1.Text))
Label1.Caption = Str(s)
End Sub
领取专属 10元无门槛券
私享最新 技术干货