在access中可以使用微软自家的程序设计语言vba进行编纯哪老程和开发,可缓改以实现自定义的功能和自动化 *** 作。vba可以与access数据库进行交互,并能够生成自定义做升的表单、报告和查询等内容,可以使access应用程序更加灵活、高效。
使用vba可以使access应用程序更加灵活、性能更高,使你能够更好地满足个性化需求、优化工作流程,提高开发和工作效率。
第一个:Public Sub prg1()Dim m As Integer, n As Integer
m = Int(Rnd() * 100)
n = Int(Rnd() * 100)
If m >n Then
temp = m
m = n
n = temp
End If
If m Mod 2 = 0 Then
m = m + 1
End If
For i = m To n Step 2
Debug.Print i
Next
End Sub
第二个:
Private Sub Command3_Click()
Me.TimerInterval = 500
Label2.FontBold = True
Label2.FontItalic = True
End Sub
Private Sub Command4_Click()
Me.TimerInterval = 0
Label2.FontBold = False
Label2.FontItalic = False
End Sub
Private Sub Form_Timer()
Label2.ForeColor = RGB(Int(Rnd() * 256), Int(Rnd() * 256), Int(Rnd() * 256))
End Sub
第三个孙蔽:
Private Sub Command2_Click()
Dim i As Integer, s As Integer, q As Integer
For i = 1 To 99 Step 2
s = s + i
Next
For i = 2 To 98 Step 2
q = q - i
Next
Text0 = s + q
End Sub
第四个:猜凯厅
Public Sub prg2()
Dim a1 As Integer, a2 As Integer, s As Integer
a1 = Val(InputBox("请输入a1"))
a2 = Val(InputBox("请输入a2"))
For i = a1 To a2 Step 2
If i Mod 2 = 1 Then
s = s + i
End If
Next
MsgBox s
End Sub
第五个:
Public Sub prg3(a As Single, b As Single, c As Single)
Dim p As Single, s As Single
If a + b >c And a + c >b And b + c >a Then
p = (a + b + c) / 2
s = Sqr(p * (p - a) * (p - b) * (p - c))
MsgBox "三角形面积为" &s
Else
MsgBox "无法构穗隐成三角形!"
End If
End Sub
第六个:
Private Sub Command4_Click()
Dim c As String, i As Integer
For i = Len(Text0) To 1 Step -1
c = c + Mid(Text0, i, 1)
Next
Text2 = c
End Sub
'计算1到100的所有偶数的和Function sum100() As Integer
Dim i As Integer
Dim iSum As Integer
iSum = 0
For i = 2 To 100 Step 2
iSum = iSum + i
Next i
sum100 = iSum
MsgBox (iSum)
iSum = 0
i = 2
While (i <= 100)
iSum = iSum + i
i = i + 2
Wend
MsgBox (iSum)
iSum = 0
i = 2
Do Until (i >100)
iSum = iSum + i
i = i + 2
Loop
MsgBox (iSum)
sum100 = iSum
End Function
'计算出1至200能被3整除的所有数, 并统计贺嫌个数
Function sum200d3() As Integer
Dim i As Integer
Dim iCount As Integer
Dim sNum As String
iCount = 0
sNum = "1至200能被3整除陪盯的所有数:"芦拍和
For i = 1 To 200
If i Mod 3 = 0 Then
sNum = sNum + Str(i) + ", "
iCount = iCount + 1
End If
Next i
MsgBox (sNum + "个数为:" + Str(iCount))
End Function
'附言: 小鬼, 作业要自己完成啊!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)