Using Function return in global variable vb.net
- by Cold Assassin
Can't seem to figure out how to use a function return variable in global Dims
example code:
Public Class Main
Dim Path As String = FixPath()
Dim fixwrongtxt As String = Path & "tryme.txt"
Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
FixPath()
On_load()
End Sub
Private Function FixPath() As String
Path = "C:\test"
MsgBox(Path) //First Message Box'
Return Path
End Function
Sub On_load()
MsgBox(fixwrongtxt) //Second Message Box
End Sub
End Class
when I run it all I get the first message box that contains "C:\test"
and I click ok and on the second messagebox I get "custom.dll" with out the "C:\test" or "Path Return" What am I doing wrong? I know I can't use // in vb.net.
I have also tried adding "FixPath()" under Sub On_load() but got same result. Also the reason I have to have these global is because I have around 30 Subs that refer to "Path" Variable... Thanks