计算机作业

今天学习了程序,这个是老师给我任务,后来通过咨询完成了。

Private Sub Command1_Click()

Dim N As Integer

Dim M As Integer

 

N = Trim(Text1.Text)

M = Trim(Text2.Text)

 

Dim number1() As Integer

Dim number2() As Integer

 

ReDim number1(Len(N))

ReDim number2(Len(M))

 

Dim index As Byte

 For index = 1 To Len(N)

    number1(index) = Mid(N, index, 1)

 

 For index = 1 To Len(M)

   numbwe(index) = Mid(M, index, 1)

  

 

 Next index

  Dim result() As Byte

  ReDim result(Len(N) + Len(M))

  Dim Mcarry As Byte, Acarry As Byte

  Dim i As Integer, j As Integer

 

For i = Len(M) To 1

For j = Len(N) To 1

   result(i + j) = (Mcarry + (number2(i) * number1(j)) Mod 10 + result(i + j)) Mod 10

   Mcarry = (number2(i) + number1(j)) \ 10

Next M

 

  result(i) = Mcarry + Acarry

   j = Len(N)

Mcarry = 0

Acarry = 0

 

End Sub

  还有计算你生日那天是星期几的程序:

Private Sub Command1_Click()

 

  Dim Year As Integer

  Dim Month As Integer

  Dim Day As Integer

  Dim n As Integer

  Dim birthday As Date

 

  Year = Int(Val(Text1.Text))

 Month = Int(Val(Text2.Text))

 Day = Int(Val(Text3.Text))

 

 birthday = DateSerial(Year, Month, Day)

 n = Weekday(birthday)

 Label6.Caption = WeekdayName(n)

 

 

 End Sub

 

Private Function myweekdayname(n As Integer) As String

Select Case n

myweekday = "星期天"

Case Else

myweekday = "非星期天"

End Function

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值