vb6.0中的模数

vb6.0中的模数,vb6,Vb6,我想问一下模数怎么不适合我 例如: Option Explicit Private Function Modulus_Operator(Value1, Value2) Modulus_Operator = Value1 - (Int(Value1 / Value2) * Value2) End Function Private Sub Form_Activate() Dim A, B, BaseOut as double A = 67^89

我想问一下模数怎么不适合我

例如:

 Option Explicit

 Private Function Modulus_Operator(Value1, Value2)

     Modulus_Operator = Value1 - (Int(Value1 / Value2) * Value2)

 End Function

 Private Sub Form_Activate()

     Dim A, B, BaseOut as double

     A = 67^89
     BaseOut = 35

     text1.text =  Modulus_Operator(A, BaseOut)

 End Sub

函数必须返回一个整数。您一定不要忘记类型:

Private Function Modulus_Operator(Value1 as integer, Value2 as integer) as integer

  Modulus_Operator = Value1 - (Int(Value1 / Value2) * Value2)

End Function

无论如何。。。你知道模的模吗?

你尝试了一些“不可能”的东西。您知道整数可以存储的值的范围吗?您的值67^89远远超出此值,因此会出现溢出。

您可以使用以下代码:

Private Sub Form_Activate()

 Dim A, B, BaseOut As Double

 A = 67 ^ 89
 BaseOut = 35

 Text1.Text = Modulus_Operator(Val(A), Val(BaseOut))

End Sub



Private Function Modulus_Operator(Value1 As Double, Value2 As Double) As Double

 Modulus_Operator = Value1 - (Int(Value1 / Value2) * Value2)

End Function

您只需编写一个mod BaseOut。这里有什么问题?请告诉我们VB6给出的错误。您想做什么?请注意-
Dim A,B,BaseOut as double
实际上意味着
Dim A as variant,B as variant,BaseOut as double