mien 发表于 2022-7-6 12:51:58

VBA错误

有人能解释一下这个编码有什么问题吗。。请注意:(
 
Private Sub getminval_Click()
'Get Minimum Value
Dim myfile2 As Integer
Dim dblX As Variant
Dim dblY As Variant
Dim dblZ As Variant
Dim strTextLine As String
Dim min_value As Integer
Dim min As Double
Dim arrText As Variant
Dim diffZ As Variant
Dim ivalue As Double
Dim i As Integer
myfile2 = FreeFile
Open mstrinpfile For Input As #myfile2
i = 0
Do While Not EOF(myfile2) = True
   Line Input #myfile2, strTextLine
   arrText = Split(strTextLine, ",")
   
   dblX(i) = arrText(0)
   dblY(i) = arrText(1)
   dblZ(i) = arrText(2)
   
   Input #myfile2, dblX(i), dblY(i), dblZ(i)
   
   ivalue = 1000
   
   diffZ = dblZ - ivalue
   
   If diffZ < 0 Then
   min = dblZ(i)
   minval.Text = Val(min)
   End If
   
   i = i + 1
      
Loop
End Sub
 
它应该通过逐个比较文件中的数据来获得最小值。。

giskumar 发表于 2022-7-6 13:42:42

嗨mien
 
在读取输入文件时尝试此语法。
 

Open "Your file path and filename with extension" For Input As #myfile2

 
如果对你有效,请告诉我。
 
 
祝你有美好的一天。。。。。

mien 发表于 2022-7-6 14:09:18

好的,谢谢。我会试着。。。。
页: [1]
查看完整版本: VBA错误