I am new in VB. I am trying to design program that count files but got the error "Name TextBox1 is not declared" kindly helpme . below is the code
Public Class Form1
Overloads Function CountFiles(ByVal minSize As Integer, ByVal maxSize As Integer) As Integer
Console.WriteLine(" You have requested the files between " & minSize & "and " & maxSize & " bytes")
Dim files() As String
files = System.IO.Directory.GetFiles("c:\windows")
Dim i, fileCount As Integer
For i = 0 To files.GetUpperBound(0)
Dim FI As New System.IO.FileInfo(files(i))
If FI.Length >= minSize And FI.Length <= maxSize Then
fileCount = fileCount + 1
End If
Next
Return (fileCount)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TexBox1.AppendText(CountFiles(1000, 100000) & "files with size between 1KB and 100KB" & vbCrLf)
End Sub
End Class
Public Class Form1
Overloads Function CountFiles(ByVal minSize As Integer, ByVal maxSize As Integer) As Integer
Console.WriteLine(" You have requested the files between " & minSize & "and " & maxSize & " bytes")
Dim files() As String
files = System.IO.Directory.GetFiles("c:\windows")
Dim i, fileCount As Integer
For i = 0 To files.GetUpperBound(0)
Dim FI As New System.IO.FileInfo(files(i))
If FI.Length >= minSize And FI.Length <= maxSize Then
fileCount = fileCount + 1
End If
Next
Return (fileCount)
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
TexBox1.AppendText(CountFiles(1000, 100000) & "files with size between 1KB and 100KB" & vbCrLf)
End Sub
End Class