VB noob在这里,处理遗留的VB 6.0应用程序.
当我在下面的函数中检查lineno的值时,我得到了预期的值:
Public Function GetNumOfLines(filename As String) As Integer
Dim lineno as Integer
lineno = 0
Open App.Path + filename For Input As #1
Do While Not EOF(1)
lineno = lineno + 1
Line Input #1, linevar
Loop
Close #1
MsgBox "numOfLines: " & lineno 'This works
End Function
Run Code Online (Sandbox Code Playgroud)
但是当我从GetATRNames(下面)调用GetNumOfLines时,numOfLines为0:
Public Function GetATRNames() As String()
Dim filename as String
filename = "\atrname.dat"
Dim numOfLines as Integer
numOfLines = GetNumOfLines(filename)
MsgBox "numOfLines: " & numOfLines 'This does not
End Function
Run Code Online (Sandbox Code Playgroud)
关于为什么numOfLines = GetNumOfLines(filename)的任何想法给我一个不同于我在GetNumOfLines中检查时的值?