搜索

VB 编成问题。急!

发布网友 发布时间:2024-10-24 09:37

我来回答

3个回答

热心网友 时间:2024-11-05 16:09

1、end 是完全结束程序进程,STOP是中断,进程未退出
2、
Private Sub command1_Click()
Dim TextLine
Open "TESTFILE" For Input As #1 ' 打开文件。
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1, A ' 读入第一个值到A
Line Input #1, B ' 读入第二个值到B
Line Input #1, C ' 读入第三个值到C
Loop
Close #1 ' 关闭文
‘结果要怎么样的?最大值还是最小值返回?当做求最大值了
if a>b then max_value=a else max_value=b
if c>max_value then max_value=C
text1=max_value '这里返回最大值到文本框中
End Sub

3、
Private Sub command1_Click()
a=val(text1)
b=val(text2)
c=val(text3)'以上为获取3个文本框的值并转换成数值型
if a>b then max_value=a else max_value=b
if c>max_value then max_value=C
text_max=max_value '这里返回最大值到文本框text_max中

if a>b then min_value=b else min_value=a
if c<min_value then min_value=C
text_min=min_value '这里返回最小值到文本框text_min中
end if
end sub

4、
Private Function jiechen(ByVal N as Integer)
jiechen=1
for i=1 to N
jiechen=jeichen * i
next i
end function

5、
text1=jiechen(8)
text1=jiechen(+6)
负数的阶乘属于高等数学,我没有学过,不知道如何算。

6、我不太理解您的问题,是不是让if-else结构和select case嵌套使用?
if a>b then
select case c
case 1
msgbox "C=1"
case 2
msgbox "C=2"
case 3
msgbox "C=3"
end select
else
msgbox "a>b"
end if

热心网友 时间:2024-11-05 16:02

1、end 是结束程序,stop......暂停
2-3,
Private Sub Form_Click()
Dim a() As String
If Text1.Text = "" Then MsgBox "输入数据先:": Exit Sub
If Right(Text1.Text, 1) = "," Then MsgBox "请使用英文状态下的逗号分割字符,且不能以逗号结束": Exit Sub
a() = Split(Text1.Text, ",")
Print "排序结果:"
For i = 0 To UBound(a)
For j = i + 1 To UBound(a)
If Val(a(i)) > Val(a(j)) Then
temp = a(i): a(i) = a(j): a(j) = temp
End If
Next
Print Val(a(i)),
Next
Print
Print "最大数="; a(UBound(a))
Print "最小数="; a(LBound(a))
End Sub

4----
Function jc(n As Integer)
Dim m, i As Integer
m = 1
If n < 0 Then
MsgBox "错误"
ElseIf n = 0 Then
MsgBox "0!=0"
Else
For i = 1 To n
m = m * i
Next
MsgBox n & "!=" & m
End If
End Function

然后在其他事件中call jc(n)
菜鸟做的,小心参考!!

热心网友 时间:2024-11-05 16:07

1.
end是退出程序,stop是暂停程序的执行,不过在编译成exe之后他们都是一样的都是退出程序。
2.
Dim s(3) As Integer
Dim i As Integer

Private Sub Command1_Click()
Dim min As Integer
Dim max As Integer
For i = 0 To 2
If i = 0 Then
min = s(i)
max = s(i)
ElseIf s(i) > max Then
max = s(i)
ElseIf s(i) < min Then
min = s(i)
End If
Next i
text1.text= "max:" & max & " " & "min:" & min

End Sub

Private Sub Text1_Change()
If Trim(Right(Text1.Text, 1)) >= 0 And Trim(Right(Text1.Text, 1)) <= 9 Then
s(i) = s(i) & Trim(Right(Text1.Text, 1))
Else
i = i + 1
End If
End Sub
3.
Private Sub Command1_Click()
Dim i As Integer
Dim Str As Double
Dim k As Integer
s = 1
i = InputBox("请输入N的值:")

For k = 1 To i
s = s * k
Next k
Text1.Text = s

End Sub
声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。
E-MAIL:11247931@qq.com
Top