VB 求大神指教···这个程序的代码···
2个回答
展开全部
Private Sub C1_Click() '设置计算按钮
Dim n As Integer, max As Integer
DoEvents '防止运算过多造成死机
For n = 1 To 18000
If Isprime(n) = True Then
max = n
End If
Next n
Text1.Text = max
End Sub
Private Function Isprime(a As Integer) As Boolean '定义素数判断函数
Dim Flag As Boolean, b%
Flag = True
b% = 2
Do While b% <= Int(a / 2) And Flag
If Int(a / b%) = a / b% Then
Flag = False
Else
b% = b% + 1
End If
Loop
Isprime = Flag
End Function
Private Sub C2_Click() '设置存盘按钮
Open "E:\shixi\out1.txt" For Append As #1
Print #1, Text1.Text
Close 1
MsgBox "保存成功!", vbOKOnly, "提示"
End Sub
代码部分大概就这样了,运算结果的话是17989,有啥问题再问我吧,希望对你有帮助~
Dim n As Integer, max As Integer
DoEvents '防止运算过多造成死机
For n = 1 To 18000
If Isprime(n) = True Then
max = n
End If
Next n
Text1.Text = max
End Sub
Private Function Isprime(a As Integer) As Boolean '定义素数判断函数
Dim Flag As Boolean, b%
Flag = True
b% = 2
Do While b% <= Int(a / 2) And Flag
If Int(a / b%) = a / b% Then
Flag = False
Else
b% = b% + 1
End If
Loop
Isprime = Flag
End Function
Private Sub C2_Click() '设置存盘按钮
Open "E:\shixi\out1.txt" For Append As #1
Print #1, Text1.Text
Close 1
MsgBox "保存成功!", vbOKOnly, "提示"
End Sub
代码部分大概就这样了,运算结果的话是17989,有啥问题再问我吧,希望对你有帮助~
网易云信
2023-12-06 广告
2023-12-06 广告
UIkit是一套轻量级、模块化且易于使用的开源UI组件库,由YOOtheme团队开发。它提供了丰富的界面元素,包括按钮、表单、表格、对话框、滑块、下拉菜单、选项卡等等,适用于各种类型的网站和应用程序。UIkit还支持响应式设计,可以根据不同...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询