NeuralJack
Centurion
- Joined
- Jul 28, 2005
- Messages
- 138
I'm wondering if there is a specific forum sub-topic that I should post various questions I might have on simple efficiency. We all know that there are tons of ways to program a certain function.. i'd like to talk, now and then, about how efficient various methods of getting the job done are. Also, whether or not that method is best for vb.net or is it old-school VB programming that should be updated.
One wouldnt really use the sub-topics, I wouldnt think, because it's not a question of implementation but more of a question of efficiency or using the best functions to get the job done. Often, the simplicity of the solution is something to consider too. If it takes 1 line to do something old-school method as opposed to 10 lines of VB.net code, that's something to factor in.
Also, is there a better VB.Net forum out there? From what i've seen this place is the best and I plan on becoming much more active here.
My question on efficient programming today is that I still use the FileOpen Function to Save/Load my settings files for my programs. It's simple and effective. Any suggestions for updating this?
I also use a while loop to read the variables it's loading from the file so that the order in which the lines are read from the file do not matter nearly as much.
Here is how I currently code loading a settings file:
One wouldnt really use the sub-topics, I wouldnt think, because it's not a question of implementation but more of a question of efficiency or using the best functions to get the job done. Often, the simplicity of the solution is something to consider too. If it takes 1 line to do something old-school method as opposed to 10 lines of VB.net code, that's something to factor in.
Also, is there a better VB.Net forum out there? From what i've seen this place is the best and I plan on becoming much more active here.
My question on efficient programming today is that I still use the FileOpen Function to Save/Load my settings files for my programs. It's simple and effective. Any suggestions for updating this?
I also use a while loop to read the variables it's loading from the file so that the order in which the lines are read from the file do not matter nearly as much.
Here is how I currently code loading a settings file:
Code:
Public Sub LoadSettingsFromFile(ByVal FileName As String)
On Error GoTo ErrorHandler
Dim fso As New Scripting.FileSystemObject()
If Not (FileName.equals(""))Then
If fso.FileExists(FileName) Then
Dim tmpString As String
Dim QuitReadingFile As Boolean = False
FileOpen(1, FileName, OpenMode.Input)
While QuitReadingFile = False And Not (EOF(1))
Input(1, tmpString)
If InStr(tmpString, "DONE") Then
QuitReadingFile = True
ElseIf InStr(tmpString, "Variable1=") Then
var1 = tmpString.Remove(0, tmpString.IndexOf("=") + 1)
ElseIf InStr(tmpString, "Variable2=") Then
var2 = tmpString.Remove(0, tmpString.IndexOf("=") + 1)
End If
End While
FileClose(1)
Else
MsgBox("Can not find the file containing the variable." + vbCrLf + _
"The Specified File = " + FileLocation_GameWindowTitle1)
End If
End If
Exit Sub
ErrorHandler:
MsgBox("An Error Occured in LoadSettingsFile SubRoutine." _
+ vbCrLf + "Error Number = " + Err.Number.ToString + vbCrLf +_
"Error Message = " + Err.Description + vbCrLf + "Error Source = "_
+ Err.Source, MsgBoxStyle.Critical, "Error Occured")
End Sub