早教吧作业答案频道 -->其他-->
VB求10000-99999之间的全部回文式素数我写的程序如下,始终显示ByRef的参数类型错误,PrivateFunctionfact(n%)AsBooleanDims%fact=TrueFors=2Ton-1IfnModi=0Thenfact=FalseExitForEndIfNextiEndFunctionPrivate
题目详情
VB 求10000-99999之间的全部回文式素数
我写的程序如下,始终显示ByRef的参数类型错误,
Private Function fact(n%) As Boolean
Dim s%
fact = True
For s = 2 To n - 1
If n Mod i = 0 Then
fact = False
Exit For
End If
Next i
End Function
Private Function hws(n%) As Boolean
Dim data%,ten%,thu%,wan%
data = n Mod 10
ten = (n \ 10) Mod 10
thu = (n \ 1000) Mod 10
wan = n \ 10000
If data = wan And ten = thu Then
hws = True
End If
End Function
Private Sub Command1_Click()
Dim ,k%
For i = 10000 To 99999
If fact(i) = True And hws(i) = True Then
k = k + 1
Print i;
If k Mod 7 = 0 Then
Print
End If
End If
Next i
End Sub
我写的程序如下,始终显示ByRef的参数类型错误,
Private Function fact(n%) As Boolean
Dim s%
fact = True
For s = 2 To n - 1
If n Mod i = 0 Then
fact = False
Exit For
End If
Next i
End Function
Private Function hws(n%) As Boolean
Dim data%,ten%,thu%,wan%
data = n Mod 10
ten = (n \ 10) Mod 10
thu = (n \ 1000) Mod 10
wan = n \ 10000
If data = wan And ten = thu Then
hws = True
End If
End Function
Private Sub Command1_Click()
Dim ,k%
For i = 10000 To 99999
If fact(i) = True And hws(i) = True Then
k = k + 1
Print i;
If k Mod 7 = 0 Then
End If
End If
Next i
End Sub
▼优质解答
答案和解析
integer % 短整型
long & 长整型
single !单精度浮点型
double # 双精度浮点型
currency @ 货币型
string $ 字符型
你的程序
Private Sub Command1_Click()
Dim i!,k%
If fact(i) = True And hws(i) = True Then
和这个地方
Private Function fact(n%) As Boolean
的传值有问题,不是同一种数据类型
long & 长整型
single !单精度浮点型
double # 双精度浮点型
currency @ 货币型
string $ 字符型
你的程序
Private Sub Command1_Click()
Dim i!,k%
If fact(i) = True And hws(i) = True Then
和这个地方
Private Function fact(n%) As Boolean
的传值有问题,不是同一种数据类型
看了VB求10000-99999之...的网友还看了以下:
VB求10000-99999之间的全部回文式素数我写的程序如下,始终显示ByRef的参数类型错误,P 2020-03-30 …
R&D人员折合全时当量是指( )A.参加R&D项目人员的全时当量B.分摊在参加R&D项目的管 2020-05-21 …
R&D人员折合全时当量是指( )A.参加R&D项目人员的全时当量B.分摊在参加R&D项目的管理和直接 2020-05-30 …
一个万有引力的题设地球半径为R.A为静止在地球赤道上的一个物体,B为地球的一颗同步卫星,其轨道半径 2020-06-07 …
设参数方程{x=r^2cosθy=r^3sin2θ1,当r是常数,θ是参数时,dy/dx=2,当θ 2020-07-31 …
用Matlab求解带参数方程R*VCC/(R*Rt/(R+Rt)+R)=Vt一个电路并联电压体想用 2020-07-31 …
求区分极坐标方程和参数方程极坐标方程是x=r*Cos(θ),y=r*Sin(θ),r是关于θ的一个 2020-08-02 …
{x=(r+1/r)cosAy=(r+1/r)sinA}(r为参数r>0)求普通方程 2020-08-02 …
VB求守形数守形数即a^2=xxa如5^2=25,25^2=625题目是求1到2000的守形数,我编 2020-11-01 …
一道VB题,麻烦说明原因.PrivateFunctionfact(nAsInteger)AsInte 2020-11-01 …