I've been using the following chunk of VBA code in Excel for a while, and though I understand what each line of code is doing I am not certain I understand some of the syntax.
What is the purpose of the #-symbol in the first line of the Do While...Loop?
I've seen it used this way in other code snippets I've looked at online, but have never seen anyone explain it. I've used it as a double type declaration before (e.g. "dVar = 0#" to assign the double "0.0" to dVar), but don't understand why it might be used that way in this instance.
I've looked for explanations, but it's an awful pain to find anything since search engines exclude the #-symbol and searching for "pound", "number", or "hash" have all sorts of other meanings.
Thanks!
What is the purpose of the #-symbol in the first line of the Do While...Loop?
I've seen it used this way in other code snippets I've looked at online, but have never seen anyone explain it. I've used it as a double type declaration before (e.g. "dVar = 0#" to assign the double "0.0" to dVar), but don't understand why it might be used that way in this instance.
I've looked for explanations, but it's an awful pain to find anything since search engines exclude the #-symbol and searching for "pound", "number", or "hash" have all sorts of other meanings.
Thanks!
Code:
Sub Read_Input_File
Dim sFileName As String, sBuf As String
Dim iFileNum As Integer
Dim sItems() As String
sFileName = [Some Valid File Location]
iFileNum = FreeFile()
Open sFileName For Input As iFileNum
Do While Not EOF(iFileNum)
Line Input #iFileNum, sBuf
sItems = Split(sBuf, ",")
[...Do Things with sItems...]
Loop
Close iFileNum
End Sub