tashiduks
Member
- Joined
- Apr 19, 2010
- Messages
- 22
- Programming Experience
- Beginner
Hi,
I am in learning process of VB.NET functions. Till now i have been using subroutine for any purpose/events. I have following subroutie to check the file exists:
I call the above subroutine on my form load which is working fine :
My question is, if i want to make the above subroutine to a function, how would i make? and how will i call the function?
I really need to learn about the function. Can anyone guide me? ALL I KNOW IS THAT, THE FUNCTION SHOLD NOT BE USED WITHOUT RETURNING VALUE.
I am using Visual Studio 2010.
Thanks.
I am in learning process of VB.NET functions. Till now i have been using subroutine for any purpose/events. I have following subroutie to check the file exists:
VB.NET:
Private Sub FileCheck()
Dim sPath As String = Application.StartupPath + "\"
Dim strError As String = ""
Dim CheckPath As Integer
Dim i As Integer
Dim FileName(4) As String
FileName(0) = "text1.txt"
FileName(1) = "text2.txt"
FileName(2) = "text3.txt"
FileName(3) = "text4.txt"
'sPath = "\"
Do
If UCase(Dir$(sPath & FileName(i))) = UCase(FileName(i)) Then
CheckPath = CheckPath + 1
Else
strError = strError & FileName(i) & vbCrLf
End If
i = i + 1
Loop Until i > 3
If CheckPath = 4 Then
'frmMain.Show()
MessageBox.Show("show form")
Else
'MessageBox.Show("The Following File(s) are Missing From " & vbCrLf & _
' sPath & vbCrLf & strError)
MessageBox.Show("The required file to run application is missing: " & vbCrLf & _
vbCrLf & strError, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Close()
End If
End Sub
I call the above subroutine on my form load which is working fine :
VB.NET:
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
FileCheck()
FileExists(True)
End Sub
My question is, if i want to make the above subroutine to a function, how would i make? and how will i call the function?
I really need to learn about the function. Can anyone guide me? ALL I KNOW IS THAT, THE FUNCTION SHOLD NOT BE USED WITHOUT RETURNING VALUE.
I am using Visual Studio 2010.
Thanks.