Results 1 to 9 of 9

Thread: progressBar

  1. #1

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    progressBar

    Hi,

    I currently have a code, and i would like my progress bar to increase while the current code is running. How can i do it?
    Thx

    request Code:
    1. using System;
    2. using System.IO;
    3. using System.Net;
    4. using System.Text;
    5.  
    6. namespace Examples.System.Net
    7. {
    8.     public class WebRequestPostExample
    9.     {
    10.         public static void Main ()
    11.         {
    12.             // Create a request using a URL that can receive a post.
    13.             WebRequest request = WebRequest.Create ("http://www.contoso.com/PostAccepter.aspx ");
    14.             // Set the Method property of the request to POST.
    15.             request.Method = "POST";
    16.             // Create POST data and convert it to a byte array.
    17.             string postData = "This is a test that posts this string to a Web server.";
    18.             byte[] byteArray = Encoding.UTF8.GetBytes (postData);
    19.             // Set the ContentType property of the WebRequest.
    20.             request.ContentType = "application/x-www-form-urlencoded";
    21.             // Set the ContentLength property of the WebRequest.
    22.             request.ContentLength = byteArray.Length;
    23.             // Get the request stream.
    24.             Stream dataStream = request.GetRequestStream ();
    25.             // Write the data to the request stream.
    26.             dataStream.Write (byteArray, 0, byteArray.Length);
    27.             // Close the Stream object.
    28.             dataStream.Close ();
    29.             // Get the response.
    30.             WebResponse response = request.GetResponse ();
    31.             // Display the status.
    32.             textbox1.text = (((HttpWebResponse)response).StatusDescription);
    33.             // Get the stream containing content returned by the server.
    34.             dataStream = response.GetResponseStream ();
    35.             // Open the stream using a StreamReader for easy access.
    36.             StreamReader reader = new StreamReader (dataStream);
    37.             // Read the content.
    38.             string responseFromServer = reader.ReadToEnd ();
    39.             // Display the content.
    40.             textbox2.text (responseFromServer);
    41.             // Clean up the streams.
    42.             reader.Close ();
    43.             dataStream.Close ();
    44.             response.Close ();
    45.         }
    46.     }
    47. }
    Last edited by met0555; Aug 17th, 2009 at 08:22 PM.

  2. #2

    Re: progressBar

    Why is this even here...? This is the wrong language!

  3. #3
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: progressBar

    ... comin back around to one of my posts, as formless has provided in his sig

    met0555, a progress bar wont be of any use here, everything's running in the sub Main which means this is a console app, no form for the progress bar to be on.

    You could get the Windows API Code Pack for VS 2008 and if the user's running Win7 your app can use the TaskBar Icon ProgressBar (which is really neat, btw)
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  4. #4

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: progressBar

    Hi,

    Sorry for C# and consol applicatoin, but i'm using the exact code but changed few lines so it works with windows apllication. If you can provide me the correct code for the progressBar with VB.net or C# it's ok with me.

    thx

  5. #5
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: progressBar

    Quote Originally Posted by met0555 View Post
    Hi,

    Sorry for C# and consol applicatoin, but i'm using the exact code but changed few lines so it works with windows apllication. If you can provide me the correct code for the progressBar with VB.net or C# it's ok with me.

    thx
    So you're using different code than what you posted, you thought that would be useful... how?

    Also, wouldn't it make more sense to either post that in the C# forum -or- post vb code of it here in the vb forum?

    We can't help you if you don't apply at least some common sense.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  6. #6

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: progressBar

    Hi,

    ok, here it is.

    vb Code:
    1. Imports System
    2. Imports System.IO
    3. Imports System.Net
    4. Imports System.Text
    5. Namespace Examples.System.Net
    6.     Public Class WebRequestGetExample
    7.  
    8.         Public Shared Sub Main()
    9.             ' Create a request for the URL.        
    10.             Dim request As WebRequest = WebRequest.Create("http://www.contoso.com/default.html")
    11.             ' If required by the server, set the credentials.
    12.             request.Credentials = CredentialCache.DefaultCredentials
    13.             ' Get the response.
    14.             Dim response As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
    15.             ' Display the status.
    16.             textbox1.text = (response.StatusDescription)
    17.             ' Get the stream containing content returned by the server.
    18.             Dim dataStream As Stream = response.GetResponseStream()
    19.             ' Open the stream using a StreamReader for easy access.
    20.             Dim reader As New StreamReader(dataStream)
    21.             ' Read the content.
    22.             Dim responseFromServer As String = reader.ReadToEnd()
    23.             ' Display the content.
    24.             textbox2.text = (responseFromServer)
    25.             ' Cleanup the streams and the response.
    26.             reader.Close()
    27.             dataStream.Close()
    28.             response.Close()
    29.         End Sub 'Main
    30.     End Class 'WebRequestGetExample
    31. End Namespace

  7. #7

    Re: progressBar

    This still isn't a vb form. It's still a console app by nature of everything being run in the Main() sub. Just because you reference textboxes doesn't mean they're actually there.

  8. #8

    Thread Starter
    Frenzied Member met0555's Avatar
    Join Date
    Jul 2006
    Posts
    1,385

    Re: progressBar

    Well ok, can you please show me how to use the progress bar while a code is running?

    thanks

  9. #9
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: progressBar

    Put a ProgressBar on the form, set it's Min and Max values then in the code use it's .Value property to set the bar's position between the Min and the Max.

    What value you set it to and when depends on how you want it to work which we can't help you with, you'll need to play with it for a while.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

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