Hi to you all, I got to read some value in a ini file ... and i always get a "Arithmetic operation resulted in an overflow."
I even found an example in the help files, that do the same. Here is the code, if somebody knows whats wrong, it would be of great help to me.
Thanks
The Code:
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Short, ByVal lpFileName As String) As Long
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim IniPath As String
Dim IniSection As String
Dim IniName As String
Dim LibName As String
Dim StrSize As Short
Dim RetVal As Integer
Dim Defaut As String
Try
IniPath = (MyPath & "\scfdata.ini"
IniSection = "Archive Settings"
IniName = "LongName"
LibName = Space(100)
StrSize = Len(LibName)
RetVal = GetPrivateProfileString(IniSection, IniName, Defaut, LibName, StrSize, IniPath)
Catch ex As Exception
Dim msg As String
msg = "HELP LINK: " & ex.HelpLink & Chr(13)
msg = msg & "SOURCE: " & ex.Source & Chr(13)
msg = msg & "MSG: " & ex.Message & Chr(13) & Chr(13)
msg = msg & ex.ToString
Me.TextBox1.Text = msg.ToString
Finally
End Try
End Sub
I even found an example in the help files, that do the same. Here is the code, if somebody knows whats wrong, it would be of great help to me.
Thanks
The Code:
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Short, ByVal lpFileName As String) As Long
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim IniPath As String
Dim IniSection As String
Dim IniName As String
Dim LibName As String
Dim StrSize As Short
Dim RetVal As Integer
Dim Defaut As String
Try
IniPath = (MyPath & "\scfdata.ini"
IniSection = "Archive Settings"
IniName = "LongName"
LibName = Space(100)
StrSize = Len(LibName)
RetVal = GetPrivateProfileString(IniSection, IniName, Defaut, LibName, StrSize, IniPath)
Catch ex As Exception
Dim msg As String
msg = "HELP LINK: " & ex.HelpLink & Chr(13)
msg = msg & "SOURCE: " & ex.Source & Chr(13)
msg = msg & "MSG: " & ex.Message & Chr(13) & Chr(13)
msg = msg & ex.ToString
Me.TextBox1.Text = msg.ToString
Finally
End Try
End Sub