分类: 电脑/网络 >> 程序设计 >> 其他编程语言
问题描述:
For j=1 to 5
a=a+jmod3
Next j
怎么算呀
解析:
msdn上是这么说的
Mod 运算符
用来对两个数作除法并且只返回余数。
语法
result = number1 Mod number2
Mod 的语法具有以下几个部分:
部分 描述
result 必需的;任何数值变量。
number1 必需的;任何数值表达式。
number2 必需的;任何数值表达式。
说明
在进行 Mod 运算或求余数运算时,该运算符将 number1 用 number2 除(将浮点数字四舍五入成整数),并把余数作为 result 的值返回。例如,在下列表达式中,A (result) 等于 5。
A = 19 Mod 67
一般说来,不管 result 是否为一个整数,result 的数据类型为 Byte,Byte 变体、Integer、Integer 变体、Long 或一个包含 Long 的 Variant。任何小数部分都被删除。但是,如果任何一个 Null,类型的表达式出现时,result 都将是 Null。任何 Empty 类型表达式都作为 0 处理。
Dim PolygonEdgeCount, Vertices_X() As Single, Vertices_Y() As Single
Dim Radius As Single, BorderColor As Single
Private Sub Command1_Click()
MePicture1Cls
Dim InitialAngle As Single
Text2 = 45 & "°/s"
BorderColor = 255
MePicture1Scale (-1000, 1000)-(1000, -1000)
Radius = MePicture1ScaleWidth 04
MePicture1PSet (0, 0), BorderColor
PolygonEdgeCount = InputBox("请输入多边形的边数:", "", 8)
If PolygonEdgeCount < 3 Or Not IsNumeric(PolygonEdgeCount) Then
MsgBox "数据错误!", 16
End
End If
Text1 = PolygonEdgeCount
ReDim Vertices_X(PolygonEdgeCount - 1) As Single, Vertices_Y(PolygonEdgeCount - 1) As Single
For i = 0 To PolygonEdgeCount - 1
Vertices_X(i) = Radius Cos(2 PI / PolygonEdgeCount i)
Vertices_Y(i) = Radius Sin(2 PI / PolygonEdgeCount i)
Next i
For i = 0 To PolygonEdgeCount - 2
MePicture1Line (Vertices_X(i), Vertices_Y(i))-(Vertices_X(i + 1), Vertices_Y(i + 1)), BorderColor
Next i
MePicture1Line (Vertices_X(LBound(Vertices_X)), Vertices_Y(LBound(Vertices_Y)))-(Vertices_X(UBound(Vertices_X)), Vertices_Y(UBound(Vertices_Y))), BorderColor
Timer1Interval = 10
End Sub
Private Sub Form_Load()
MePicture1Width = 3600
MePicture1Height = 3600
MePicture1BackColor = &H0&
MePicture1AutoRedraw = True
MePicture1DrawWidth = 3
End Sub
Private Sub Timer1_Timer()
MeCaption = Time
Dim AngularVelocity As Single
MePicture1Cls
Static n As Integer
AngularVelocity = 45 PI / 18000
n = n + 1
For i = 0 To PolygonEdgeCount - 1
Vertices_X(i) = Radius Cos(2 PI / PolygonEdgeCount i + AngularVelocity n)
Vertices_Y(i) = Radius Sin(2 PI / PolygonEdgeCount i + AngularVelocity n)
Next i
Text4 = Vertices_X(0): Text5 = Vertices_Y(0)
MePicture1PSet (0, 0), BorderColor
For i = 0 To PolygonEdgeCount - 2
MePicture1Line (Vertices_X(i), Vertices_Y(i))-(Vertices_X(i + 1), Vertices_Y(i + 1)), BorderColor
Next i
MePicture1Line (Vertices_X(LBound(Vertices_X)), Vertices_Y(LBound(Vertices_Y)))-(Vertices_X(UBound(Vertices_X)), Vertices_Y(UBound(Vertices_Y))), BorderColor
If n >= 800 Then n = 0
End Sub
以上就是关于VB 6.0程序设计中,Mod 是怎么算的。 并举个例全部的内容,包括:VB 6.0程序设计中,Mod 是怎么算的。 并举个例、VB6.0程序设计,多边形颜色大小自定,多边形边数由用户输入,要求每1秒逆时针转动45度、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)