Results 1 to 13 of 13

Thread: Downloading a file

  1. #1
    Guest

    Post

    How do i download a file to the c drive using vb?

  2. #2
    Guest
    Also, how do i perform an action based on whats selected in a list box?

  3. #3
    Addicted Member New2VB's Avatar
    Join Date
    Jun 2000
    Location
    Los Angeles
    Posts
    161

    Smile ListBoxes

    I'm a new guy so I hope this is helpful.

    As to the 2nd question:

    I think you want to look at the ListIndex property and use it to control the flow of your application, e.g., assuming a list and a button where the trigger is the button and the list is the modifier, you might have the following:

    Code:
     
    
    Private Sub Command1_Click()
        Select Case List1.ListIndex
            Case 0
                MsgBox "Item 1"
            Case 1
                MsgBox "Item 2"
            Case 2
                MsgBox "Item 3"
        End Select
    End Sub
    
    Private Sub Form_Load()
        List1.AddItem "First"
        List1.AddItem "Second"
        List1.AddItem "Third"
    End Sub
    Hope it helps.

    Regards
    NEW2VB

  4. #4
    Lively Member
    Join Date
    May 1999
    Location
    Singapore
    Posts
    116
    for downloading files, you can take a look at the tutorial in vb world for using the inet control...

    as for performing an action, you can use List1.ListIndex to retrieve the number of the item that was selected, or use List1.List(List1.ListIndex) to get the string that was selected in the listbox
    YC Sim
    Teenage Programmer
    UIN 37903254



  5. #5
    Guest
    Code:
    Private Sub Command1_Click()
        Dim F As Form
        Select Case List1.Text
            Case "Hello"
                frmHello.Show
            Case "About"
                frmAbout.Show
            Case "End"
                For Each F In Forms
                    Unload F
                Next F
        End Select
    End Sub

  6. #6
    Guest
    I couldnt find that demo, could someone just explain it to me.

  7. #7
    Guest
    Try one of these:

    Try the execute command.

    Code:
    Inet1.Execute "http://www.somewhere.com/index.html", "GET"
    or download pictures or files with the Inet control.

    Code:
    Dim iFile As Integer
    Dim bBIN As Byte
    Inet1.Cancel ' Stops any current operations 
    Inet1.AccessType = icUseDefault 
    Caption = "Downloading.."
    bBIN = Inet1.OpenURL("www.vb-world.net/images/vbworld.gif", icByteArray)
    iFile = FreeFile
    Open "C:\vbworld.gif" For Binary Access Write As iFile
    Put #iFile, , bBIN
    Close iFile
    Caption = "Download Complete."
    Hope that helps.

  8. #8
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455
    Dear Matthew Gates,

    I can't get the code running. Some objects are not understood.
    Please can you references?

    Thanks a lot.

    Michelle.

  9. #9
    Fanatic Member Dim's Avatar
    Join Date
    Jul 2000
    Posts
    620
    Make sure you added the iNET control to your form eh...
    Laterz,
    d!m

    [Edited by Dim on 07-14-2000 at 02:43 AM]
    Dim

  10. #10
    Guest
    Originally posted by michelle
    Dear Matthew Gates,

    I can't get the code running. Some objects are not understood.
    Please can you references?

    Thanks a lot.

    Michelle.
    What version of MSInet.ocx are you using? Does it give you the error message that it can't load on the form? Well...I have a solution for that....and you can download the fix for it here: http://www.planet-source-code.com/vb...txtCodeId=4860

  11. #11
    Lively Member
    Join Date
    May 1999
    Location
    Singapore
    Posts
    116
    i suppose the bBin has to be declared as
    Dim bBin() as Byte
    YC Sim
    Teenage Programmer
    UIN 37903254



  12. #12
    Guest
    Originally posted by ycsim
    i suppose the bBin has to be declared as
    Dim bBin() as Byte
    You are correct .

    Code:
    Dim iFile As Integer
    Dim bBIN() As Byte
    Inet1.Cancel ' Stops any current operations 
    Inet1.AccessType = icUseDefault 
    Caption = "Downloading.."
    bBIN() = Inet1.OpenURL("www.vb-world.net/images/vbworld.gif", icByteArray)
    iFile = FreeFile
    Open "C:\vbworld.gif" For Binary Access Write As iFile
    Put #iFile, , bBIN()
    Close iFile
    Caption = "Download Complete."
    Maybe that'll work now.

  13. #13
    Hyperactive Member Datacide's Avatar
    Join Date
    Jun 2005
    Posts
    309

    Re: Downloading a file

    Code:
    Dim iFile As Integer
    Dim bBIN() As Byte
    Inet1.Cancel ' Stops any current operations 
    Inet1.AccessType = icUseDefault 
    Caption = "Downloading.."
    bBIN() = Inet1.OpenURL("www.vb-world.net/images/vbworld.gif", icByteArray)
    iFile = FreeFile
    Open "C:\vbworld.gif" For Binary Access Write As iFile
    Put #iFile, , bBIN()
    Close iFile
    Caption = "Download Complete."
    Is this the fasted way to download a picture?
    PHP in your FACE!

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