Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Code Is Not Working .

Code Is Not Working .

Scheduled Pinned Locked Moved Visual Basic
csharpcomgraphicssysadmin
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dan Suthar
    wrote on last edited by
    #1

    Hi, I got a downloader program form internet but it was made in C# . I converted it to VB.NET . There is no errors in the code , but it isn't working !:doh: Here is the few code form the whole project which is not working: Imports System.IO Imports System.Net Imports System.Text Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Drawing Imports System.Windows.Forms Imports System.Threading Public Class Download Private thrDownload As Thread ' The stream of data retrieved from the web server Private strResponse As Stream ' The stream of data that we write to the harddrive Private strLocal As Stream ' The request to the web server for file information Private webRequest As HttpWebRequest ' The response from the web server containing information about the file Private webResponse As HttpWebResponse ' The progress of the download in percentage Private Shared PercentProgress As Integer ' The delegate which we will call from the thread to update the form Private Delegate Sub UpdateProgessCallback(ByVal BytesRead As Int64, ByVal TotalBytes As Int64) ' When to pause Private goPause As Boolean = False Private Sub Download(ByVal startPoint As Object) Try Dim startPointInt As Integer = Convert.ToInt32(startPoint) ' Create a request to the file we are downloading webRequest = DirectCast(Net.WebRequest.Create("http://dl.google.com/picasa/picasaweb-current-setup.exe"), HttpWebRequest) ' Set the starting point of the request webRequest.AddRange(startPointInt) ' Set default authentication for retrieving the file webRequest.Credentials = CredentialCache.DefaultCredentials ' Retrieve the response from the server webResponse = DirectCast(webRequest.GetResponse(), HttpWebResponse) ' Ask the server for the file size and store it Dim fileSize As Int64 = webResponse.ContentLength ' Open the URL for download strResponse = webResponse.GetResponseStream() ' Create a new file stream where we will be saving the data (local drive) If startPointInt = 0 Then strLocal = New FileStream("C:\", FileMode.Create, FileAccess.Write, FileShare.None) Else strLocal = New FileStream("C:\", FileMode.Append, FileAccess.Write, Fil

    P S 2 Replies Last reply
    0
    • D Dan Suthar

      Hi, I got a downloader program form internet but it was made in C# . I converted it to VB.NET . There is no errors in the code , but it isn't working !:doh: Here is the few code form the whole project which is not working: Imports System.IO Imports System.Net Imports System.Text Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Drawing Imports System.Windows.Forms Imports System.Threading Public Class Download Private thrDownload As Thread ' The stream of data retrieved from the web server Private strResponse As Stream ' The stream of data that we write to the harddrive Private strLocal As Stream ' The request to the web server for file information Private webRequest As HttpWebRequest ' The response from the web server containing information about the file Private webResponse As HttpWebResponse ' The progress of the download in percentage Private Shared PercentProgress As Integer ' The delegate which we will call from the thread to update the form Private Delegate Sub UpdateProgessCallback(ByVal BytesRead As Int64, ByVal TotalBytes As Int64) ' When to pause Private goPause As Boolean = False Private Sub Download(ByVal startPoint As Object) Try Dim startPointInt As Integer = Convert.ToInt32(startPoint) ' Create a request to the file we are downloading webRequest = DirectCast(Net.WebRequest.Create("http://dl.google.com/picasa/picasaweb-current-setup.exe"), HttpWebRequest) ' Set the starting point of the request webRequest.AddRange(startPointInt) ' Set default authentication for retrieving the file webRequest.Credentials = CredentialCache.DefaultCredentials ' Retrieve the response from the server webResponse = DirectCast(webRequest.GetResponse(), HttpWebResponse) ' Ask the server for the file size and store it Dim fileSize As Int64 = webResponse.ContentLength ' Open the URL for download strResponse = webResponse.GetResponseStream() ' Create a new file stream where we will be saving the data (local drive) If startPointInt = 0 Then strLocal = New FileStream("C:\", FileMode.Create, FileAccess.Write, FileShare.None) Else strLocal = New FileStream("C:\", FileMode.Append, FileAccess.Write, Fil

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      Unlike C#, VB.NET doesn't allow variable assignment within a While loop header. You should modify your code to take account of this language difference.

      Paul Marfleet

      1 Reply Last reply
      0
      • D Dan Suthar

        Hi, I got a downloader program form internet but it was made in C# . I converted it to VB.NET . There is no errors in the code , but it isn't working !:doh: Here is the few code form the whole project which is not working: Imports System.IO Imports System.Net Imports System.Text Imports System Imports System.Collections.Generic Imports System.ComponentModel Imports System.Data Imports System.Drawing Imports System.Windows.Forms Imports System.Threading Public Class Download Private thrDownload As Thread ' The stream of data retrieved from the web server Private strResponse As Stream ' The stream of data that we write to the harddrive Private strLocal As Stream ' The request to the web server for file information Private webRequest As HttpWebRequest ' The response from the web server containing information about the file Private webResponse As HttpWebResponse ' The progress of the download in percentage Private Shared PercentProgress As Integer ' The delegate which we will call from the thread to update the form Private Delegate Sub UpdateProgessCallback(ByVal BytesRead As Int64, ByVal TotalBytes As Int64) ' When to pause Private goPause As Boolean = False Private Sub Download(ByVal startPoint As Object) Try Dim startPointInt As Integer = Convert.ToInt32(startPoint) ' Create a request to the file we are downloading webRequest = DirectCast(Net.WebRequest.Create("http://dl.google.com/picasa/picasaweb-current-setup.exe"), HttpWebRequest) ' Set the starting point of the request webRequest.AddRange(startPointInt) ' Set default authentication for retrieving the file webRequest.Credentials = CredentialCache.DefaultCredentials ' Retrieve the response from the server webResponse = DirectCast(webRequest.GetResponse(), HttpWebResponse) ' Ask the server for the file size and store it Dim fileSize As Int64 = webResponse.ContentLength ' Open the URL for download strResponse = webResponse.GetResponseStream() ' Create a new file stream where we will be saving the data (local drive) If startPointInt = 0 Then strLocal = New FileStream("C:\", FileMode.Create, FileAccess.Write, FileShare.None) Else strLocal = New FileStream("C:\", FileMode.Append, FileAccess.Write, Fil

        S Offline
        S Offline
        Scott Dorman
        wrote on last edited by
        #3

        First, please use the <pre> tags when posting large snippets of code. It helps keep the formatting and makes it much easier to read. Secondly, why are you converting the code? If the original project was written properly, you should be able to include the C# project in your solution or compile it separately and include the reference in your VB project to the DLL. There are already several file downloader components here on CP that I know will work with VB code in the manner I describe above. You can check out this one[^] as a start.

        Scott.


        —In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]

        D 1 Reply Last reply
        0
        • S Scott Dorman

          First, please use the <pre> tags when posting large snippets of code. It helps keep the formatting and makes it much easier to read. Secondly, why are you converting the code? If the original project was written properly, you should be able to include the C# project in your solution or compile it separately and include the reference in your VB project to the DLL. There are already several file downloader components here on CP that I know will work with VB code in the manner I describe above. You can check out this one[^] as a start.

          Scott.


          —In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]

          D Offline
          D Offline
          Dan Suthar
          wrote on last edited by
          #4

          Scott Dorman wrote:

          First, please use the "pre" tags when posting large snippets of code. It helps keep the formatting and makes it much easier to read.

          Sorry , I was my mistake .:-> You suggested the perfect suggestion. Thanks. :)

          S 1 Reply Last reply
          0
          • D Dan Suthar

            Scott Dorman wrote:

            First, please use the "pre" tags when posting large snippets of code. It helps keep the formatting and makes it much easier to read.

            Sorry , I was my mistake .:-> You suggested the perfect suggestion. Thanks. :)

            S Offline
            S Offline
            Scott Dorman
            wrote on last edited by
            #5

            Dan`M wrote:

            Sorry , I was my mistake

            No problem. Just wanted to let you know for the future.

            Dan`M wrote:

            You suggested the perfect suggestion. Thanks.

            You're welcome.

            Scott.


            —In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups