vb程序设计:编写一函数,求两数中较大数,利用窗体单击事件给函数传值并输出结果到窗体上

vb程序设计:编写一函数,求两数中较大数,利用窗体单击事件给函数传值并输出结果到窗体上,第1张

Private Sub Command1_Click()

If Text1Text <> "" And Text2Text <> "" Then

Call qiuzhi(CInt(Text1Text), CInt(Text2Text))

Else

MsgBox "请输入两个数"

End If

End Sub

Private Function qiuzhi(ByVal m, n As Integer)

Dim max, min As Integer

If m > n Then

max = m

min = n

Else

max = n

min = m

End If

MsgBox "最大值是:" & max & ";最小值是:" & min

End Function

#include<stdioh> int fun(); void main(void) { int i,n,a[500]; n = fun(a); for(i = 0; i < n; i++) printf("%d ",a[i]); } int fun (int a[]) { int i = 7, j = 0; for(; i <= 1000; i++) if (i % 7 == 0 || i % 11 == 0) if ( !(i % 77 == 0 && i % 11 == 0) ) a[j++] = i; return j ; }

这是楼主要的函数过程(先在窗体上添加一个命令按钮)

Private Sub Command1_Click()

Dim n As Integer

n = 100

f n

End Sub

Function f(n As Integer) As Single

Dim i As Integer

For i = 1 To n

f = f + 1 / i

Next i

Print "1+1/2+1/3+…+1/100结果为:" & f

End Function

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

原文地址: http://outofmemory.cn/langs/11676574.html

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

发表评论

登录后才能评论

评论列表(0条)

保存