Results 1 to 12 of 12

Thread: progress bar

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Posts
    307

    progress bar

    once i add a pogress bar, how do i code it, can i get a example?

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: progress bar

    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.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Posts
    307

    Re: progress bar

    its for this you or gigemboy wrote for me:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         'to call the sub
    3.         RecursiveList("c:\", "exe")
    4.     End Sub
    5.     'the sub code..
    6.     Private Sub RecursiveList(ByVal strSearch As String, ByVal strFind As String)
    7.         Try
    8.             Dim MyDirectory As System.IO.Directory 'directory declaration
    9.             Dim MyDirs() As String 'string array holding directory names
    10.             MyDirs = MyDirectory.GetDirectories(strSearch) 'gets current directories
    11.             Dim str As String
    12.             For Each str In MyDirs 'loops for every string in MyDirs
    13.                 Dim strFiles() As String 'string array for Files in Directory
    14.                 strFiles = MyDirectory.GetFiles(strSearch) 'gets files in directory
    15.                 Dim strReturn As String
    16.                 Dim strReturn2 As String
    17.  
    18.                 For Each strReturn In strFiles 'loops for every file in the array
    19.                     Dim strCompare As String
    20.                     strCompare = Strings.Right(strReturn, 3)
    21.  
    22.                     If strCompare = "exe" Then
    23.                         Dim I As Integer = 1
    24.                         Do
    25.                             strCompare = Strings.Right(strReturn, I + 3)
    26.                             If Strings.Left(strCompare, 1) = "\" Then
    27.                                 ListBox1.Items.Add(Strings.Right(strReturn, I + 2))
    28.                                 Me.Refresh()
    29.                                 Exit Do
    30.                             Else
    31.                                 I = I + 1
    32.                             End If
    33.                         Loop
    34.                     End If
    35.                 Next
    36.                 Dim SW As IO.StreamWriter = IO.File.CreateText("currentexecutables.txt")
    37.                 For Each S As String In ListBox1.Items
    38.                     SW.WriteLine(S)
    39.                 Next
    40.                 SW.Close()
    41.                 'This calls the Function inside of itself, for every directory in the initial directory, hence "Recursion"
    42.                 RecursiveList(str, strFind)
    43.             Next
    44.  
    45.         Catch
    46.         End Try
    47.         Exit Sub
    48.  
    49.  
    50.     End Sub

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: progress bar

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2005
    Posts
    307

    Re: progress bar

    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

  6. #6
    Junior Member
    Join Date
    Oct 2005
    Posts
    23

    Re: progress bar

    Ya, MSDN, they should have a certification on just reading the help..

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: progress bar

    Quote Originally Posted by ruckus37
    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:
    VB Code:
    1. Private Sub CopyWithProgress(ByVal ParamArray filenames As String())
    2.     ' Display the ProgressBar control.
    3.     pBar1.Visible = True
    4.     ' Set Minimum to 1 to represent the first file being copied.
    5.     pBar1.Minimum = 1
    6.     ' Set Maximum to the total number of files to copy.
    7.     pBar1.Maximum = filenames.Length
    8.     ' Set the initial value of the ProgressBar.
    9.     pBar1.Value = 1
    10.     ' Set the Step property to a value of 1 to represent each file being copied.
    11.     pBar1.Step = 1
    12.  
    13.     ' Loop through all files to copy.
    14.     Dim x As Integer
    15.     for x = 1 To filenames.Length - 1
    16.         ' Copy the file and increment the ProgressBar if successful.
    17.         If CopyFile(filenames(x - 1)) = True Then
    18.             ' Perform the increment on the ProgressBar.
    19.             pBar1.PerformStep()
    20.         End If
    21.     Next x
    22. End Sub
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8
    Junior Member
    Join Date
    Oct 2005
    Posts
    23

    Re: progress bar

    Ya, MSDN, they should have a certification on just "searching" for the help..

  9. #9
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: progress bar

    Quote Originally Posted by ruckus37
    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  10. #10
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142

    Re: progress bar

    You should be certified if you can't do that
    lol, i'm trying to eat here.
    difficult while laughing
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  11. #11
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: progress bar

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  12. #12
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: progress bar

    Quote Originally Posted by jmcilhinney
    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....

    Something about horses and water....

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width