vb期末考试程序题

vb期末考试程序题,第1张

Private Sub cmdStart_Click()

cmdNext.【Enabled】 = True

cmdCheck.Enabled = True

cmdStart.Enabled = False

【call】 GenerateRND

End Sub

Public Sub GenerateRND()

lblFirst.Caption = Int(【100 * rnd】缺芦伏)

lblSecond.Caption = Int(【100 * rnd】)

End Sub

Private Sub cmdCheck_Click()

Dim operand As String

Dim var1 As Integer

Dim var2 As Integer

var1 = 【val】(lblFirst.Caption)

var2 = 【val】(lblSecond.Caption)

For i = 0 To 3

If 【optOperator(i)】 .Value = true Then

operand = 【optOperator(i)】 .caption

End If

Next

Select Case 【operand】

Case “+”

result = var1 + var2

Case “-”

result = var1 - var2

Case “*”

result = var1 * var2

Case “/”

result = var1 / var2

End Select

If result = Val(txtResult.【text】) Then

【msgbox】 (“计算正确!”哗配)

Else

【msgbox】 (“错,请重新计算!”)

End If

End Sub

Private Sub cmdNext_Click()

Call 【GenerateRND】

End Sub

Private Sub cmdExit_Click()

【伏携end】

End Sub

画四个TEXT 文本,分别输入A,x,y,z

注意输入是数字哦

一个按钮。直接复制代码到VB中看,

(碰掘缺起先有事才没回你散悄呢,你的消息我也没看到,,回来了才发现你作业交了哈哈,,,)

Private Sub Command1_Click()

Dim a As Integer

Dim x As Integer

Dim y As Integer

Dim z As Integer

a = Text1.Text

x = Text2.Text

y = Text3.Text

z = Text4.Text

Dim ax As Integer

Dim ay As Integer

Dim az As Integer

Dim m As Integer

Dim N(1000) As Integer '1000应该够了,,不会超标吧哈哈,,浪费点资源

Dim Nx(1000) As Integer

Dim Ny(1000) As Integer

Dim Nz(1000) As Integer

Dim s As Integer

m = 0

ax = (a - a Mod x) / x

ay = (a - a Mod y) / y

az = (a - a Mod z) / z

Dim fx As Integer

Dim fy As Integer

Dim fz As Integer

For fx = 1 To ax

For fy = 1 To ay

For fz = 1 To az

s = a - fx * x - fy * y - fz * z

If s >0 Then

m = m + 1

N(m) = s

Nx(m) = fx

Ny(m) = fy

Nz(m) = fz

End If

Next fz

Next fy

Next fx '各种情况都存笑辩入数组了

'============================下面比较大小==================

Dim kk As Integer

Dim min As Integer

Dim minx As Integer

Dim miny As Integer

Dim minz As Integer

min = N(1)

For kk = 1 To m - 1

If N(kk) <= min Then

min = N(kk)

minx = Nx(kk)

miny = Ny(kk)

minz = Nz(kk)

End If

Next kk

Print "最小余为:" &min

Print "x截的段数为:" &minx

Print "x截的段数为:" &miny

Print "x截的段数为:" &minz

End Sub

1、KeyPress

2、KeyAscii >=48 AND KeyAscii <=57

3、Text2.Text &Chr(KeyAscii)

以上是在Text2上将每次符合条件轿键的字符都依次连接起来显示。如果是每次要在Text2上只显示一团庆个字符,则将第3空闭或巧改为:

Chr(KeyAscii)


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/12385429.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-25
下一篇 2023-05-25

发表评论

登录后才能评论

评论列表(0条)

保存