once i add a pogress bar, how do i code it, can i get a example?
Printable View
once i add a pogress bar, how do i code it, can i get a example?
what are you using it for? its pretty simple to use a progress bar, you set a min and max property (min is usually 0, max is usually the count of whatever it is you need the prog bar for)
generally you increment it by 1 while in a loop so that once the loop has finished, the progress bar is at 100.
so wherever the loop is that you are running, the increment step should be in there.
its for this you or gigemboy wrote for me:
VB Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click 'to call the sub RecursiveList("c:\", "exe") End Sub 'the sub code.. Private Sub RecursiveList(ByVal strSearch As String, ByVal strFind As String) Try Dim MyDirectory As System.IO.Directory 'directory declaration Dim MyDirs() As String 'string array holding directory names MyDirs = MyDirectory.GetDirectories(strSearch) 'gets current directories Dim str As String For Each str In MyDirs 'loops for every string in MyDirs Dim strFiles() As String 'string array for Files in Directory strFiles = MyDirectory.GetFiles(strSearch) 'gets files in directory Dim strReturn As String Dim strReturn2 As String For Each strReturn In strFiles 'loops for every file in the array Dim strCompare As String strCompare = Strings.Right(strReturn, 3) If strCompare = "exe" Then Dim I As Integer = 1 Do strCompare = Strings.Right(strReturn, I + 3) If Strings.Left(strCompare, 1) = "\" Then ListBox1.Items.Add(Strings.Right(strReturn, I + 2)) Me.Refresh() Exit Do Else I = I + 1 End If Loop End If Next Dim SW As IO.StreamWriter = IO.File.CreateText("currentexecutables.txt") For Each S As String In ListBox1.Items SW.WriteLine(S) Next SW.Close() 'This calls the Function inside of itself, for every directory in the initial directory, hence "Recursion" RecursiveList(str, strFind) Next Catch End Try Exit Sub End Sub
May I suggest that before you ask a question like this that you consult the MSDN library. The help topic for the ProgressBar class has a code example already, as well as a link to the member listing, which in turn links to detailed descriptions of each member. MSDN should ALWAYS be your first port of call.
i did but i didnt understand how to apply it to my function. trust me, i try to help myself first even though it dont seem like it
Ya, MSDN, they should have a certification on just reading the help..
The fact that some topics are complex is not a reason not to look there first. Some of the subjects dealt with are complex, so of course the explanations must be. Others are not so complex. Here's the code example from the topic for the ProgressBar class:Quote:
Originally Posted by ruckus37
How is that more complicated than an example any of us would provide ourselves? The topic also contains links to more information about the ProgressBar and its members as well, so you can get a fuller understanding of the class and how to use it, which reduces the likelihood that you'd need to ask more questions in the future. The more you use a resource like MSDN, the more familiar it becomes and therefore the easier it becomes. It was my primary source of information when teaching myself VB.NET, no certification required.Quote:
VB Code:
Private Sub CopyWithProgress(ByVal ParamArray filenames As String()) ' Display the ProgressBar control. pBar1.Visible = True ' Set Minimum to 1 to represent the first file being copied. pBar1.Minimum = 1 ' Set Maximum to the total number of files to copy. pBar1.Maximum = filenames.Length ' Set the initial value of the ProgressBar. pBar1.Value = 1 ' Set the Step property to a value of 1 to represent each file being copied. pBar1.Step = 1 ' Loop through all files to copy. Dim x As Integer for x = 1 To filenames.Length - 1 ' Copy the file and increment the ProgressBar if successful. If CopyFile(filenames(x - 1)) = True Then ' Perform the increment on the ProgressBar. pBar1.PerformStep() End If Next x End Sub
Ya, MSDN, they should have a certification on just "searching" for the help..
Enter "progressbar class" as the search term, set the search scope to "MSDN Library" and press the "Go" button. The first result returned is entitled "ProgressBar Class (.NET Framework)". You should be certified if you can't do that. Like I said the more you use it the easier it becomes. I almost always search for "<class name here> class" or "<class name here> members" because every class in the .NET Framework has a an overview topic and a member listing entitled in that way. Once you get to one of those pages you can usually follow the links from there. The sooner you stop making excuses and learn to use the resources at your disposal the quicker your programming ability will improve.Quote:
Originally Posted by ruckus37
lol, i'm trying to eat here.Quote:
You should be certified if you can't do that
difficult while laughing :rolleyes: ;)
I seek only to entertain. ;) But seriously, I've lost count of the questions I've answered on topics I have had little or no previous experience with simply by doing a quick search on MSDN. Again, the more you use it the better you get at it, like anything, but surely anyone can find the help topic for a particular class.
That's why I've stopped responding to such threads..... There have been a number lately that could have been easily answered by checking MSDN or just doing a simple search on VBF or even google....Quote:
Originally Posted by jmcilhinney
Something about horses and water....
-tg