您的位置:首页 > 编程语言 > VB

VB作业

2016-04-21 12:32 162 查看
一.用Timer算加法

Private Sub Timer1_Time

sum = sum + i

i = i + 1

If i > 100 Then

Me.Timer1.Ebable = Falze

Print sum

End Sub

二.阶乘算法

Private Sub Command1_Click()

Cls

Print
阶乘(12)

End Sub

Private Function
阶乘(n As Integer)As Long

If n = 1 Then

阶乘 = 1

Else

阶乘 = n ×
阶乘(n-1)

End If

End Function

三.两个
一位数
相乘

Private Sub Command1_Click()

Cls

Dim n1 As Byte

Dim n2 As Byte

Dim yushu As Byte

Dim shang As Byte

Dim tempResult As Byte

n1 = Int(Me.Text1.Text)

n2 = Int(Me.Text2.Text)

tempResult = n1*n2

yushu = tempResult Mod 10

shang = tempResult \ 10

Print shang & yushu

End up

四.两位数

一位数

Private Sub Command1_Click()

Cls

Dim n1()
As Byte,n1len As Long

Dim n2()
As Byte,n2len As Long

Dim yushu1 As Byte,yushu2 As Byte

Dim shang As Byte

Dim tempResult As Byte

n1len = Len(Me.Text1.Text)

n2len = Len(Me.Text2.Text)

ReDim n1(n1len)

ReDim n2(n2len)

For i = LBound(n1) To UBound(n1)

n1(i) = Int(Val(Mid(Me.Text1.Text , i , 1)))

Next

For i = LBound(n2) To UBound(n2)

n2(i) = Int(Val(Mid(Me.Text2.Text , i , 1)))

Next

tempResult = n1(2)*n2(1)+shang

yushu1 = tempResult Mod 10

shang = tempResult \ 10

tempResult = n1(2)*n2(1)+shang

yushu2 = tempResult Mod 10

shang = tempResult \ 10

Print shang & yushu2 & yushu1

End up
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: