VERSION 5.00
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form Форма1 
   BackColor       =   &H00FFC0C0&
   Caption         =   "Форма1"
   ClientHeight    =   5685
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   6390
   LinkTopic       =   "Форма1"
   ScaleHeight     =   5685
   ScaleWidth      =   6390
   StartUpPosition =   3  'Окна По Умолчанию
   Begin VB.CommandButton Комманда2 
      Caption         =   "Скачать2"
      Height          =   555
      Left            =   3630
      TabIndex        =   10
      Top             =   4800
      Width           =   1305
   End
   Begin VB.TextBox Label3 
      Height          =   885
      Left            =   3000
      MultiLine       =   -1  'True
      TabIndex        =   9
      Top             =   3090
      Width           =   3225
   End
   Begin VB.TextBox Text2 
      Height          =   345
      Left            =   660
      TabIndex        =   2
      Text            =   "C:\TEX.txt"
      Top             =   630
      Width           =   5115
   End
   Begin InetCtlsObjects.Inet Inet1 
      Left            =   750
      Top             =   3120
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      URL             =   "http://"
   End
   Begin VB.TextBox Text1 
      Height          =   345
      Left            =   630
      TabIndex        =   1
      Text            =   "http://mail.yandex.ru/neo/message?current_folder=2040001100005451022&ids=2040000000373507774"
      Top             =   150
      Width           =   5115
   End
   Begin VB.CommandButton Комманда1 
      Caption         =   "Скачать"
      Height          =   495
      Left            =   1110
      TabIndex        =   0
      Top             =   4140
      Width           =   1815
   End
   Begin VB.Label Метка6 
      Caption         =   "Статус"
      Height          =   255
      Left            =   1200
      TabIndex        =   8
      Top             =   2550
      Width           =   1515
   End
   Begin VB.Label Метка5 
      Caption         =   "Куда"
      Height          =   255
      Left            =   1200
      TabIndex        =   7
      Top             =   1950
      Width           =   1515
   End
   Begin VB.Label Метка4 
      Caption         =   "Откуда"
      Height          =   255
      Left            =   1200
      TabIndex        =   6
      Top             =   1320
      Width           =   1515
   End
   Begin VB.Label k 
      Caption         =   "Метка1"
      Height          =   525
      Left            =   3000
      TabIndex        =   5
      Top             =   2460
      Width           =   4155
   End
   Begin VB.Label Label2 
      Caption         =   "http://hiprog.com/forum/files/6279-20091205210709.txt"
      Height          =   525
      Left            =   3000
      TabIndex        =   4
      Top             =   1770
      Width           =   4155
   End
   Begin VB.Label Label1 
      Caption         =   $"Форма1.frx":0000
      Height          =   525
      Left            =   3000
      TabIndex        =   3
      Top             =   1170
      Width           =   4155
   End
End
Attribute VB_Name = "Форма1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim DownloadWorking As Boolean
 Dim bWorking As Boolean

 Private Sub Command2()


     Dim bData() As Byte
    'установка протокола для Inet1
    Me.Inet1.Protocol = icHTTP
    'установка URL для Inet1
   Me.Inet1.URL = Text1.Text
     'проверяем значение флага bWorking
    'если bWorking ложно, то начинаем скачивание
If bWorking = False Then
     'устанавливаем флаг bWorking - скачивание началось
        bWorking = True
         'выключаем кнопку, стартующую закачку
          Комманда2.Enabled = False
         'скачиваем файл в массив bData
         bData() = Me.Inet1.OpenURL(Me.Inet1.URL, icByteArray)
         'снимаем флаг bWorking - скачивание закончилось
         bWorking = False
         'включаем кнопку, стартующую закачку
          Комманда2.Enabled = True
End If
     'записываем данные из массива bData в файл
     Open "C:\TEX.txt" For Binary Access Write As #1
     Put #1, , bData()
     Close #1
 End Sub










Private Sub Комманда1_Click()
Call Downloads
End Sub



Public Function Downloads()
Dim FileNumber As Integer


If DownloadWorking = False Then
    DownloadWorking = True
    Dim b() As Byte
    Me.Inet1.Protocol = icHTTP
    Me.Inet1.URL = Text1.Text
    Me.Inet1.Password = "e2e2e2" '"rsGtuqnL"
    Me.Inet1.UserName = "serz58" '"ewerest"
    b() = Me.Inet1.OpenURL(Me.Inet1.URL, icByteArray)
    FileNumber = FreeFile()
    Open Text2.Text For Binary Access Write As #FileNumber
    Put #FileNumber, , b()
    Close #FileNumber
    DownloadWorking = False
End If
End Function
Private Sub Inet1_StateChanged(ByVal State As Integer)
Label3.Text = GetState(State)
End Sub
Private Function GetState(s As Integer) As String
Select Case s
  Case 0
      GetState = "No state information is available."
 
  Case 1
      GetState = "Looking up the IP address for the remote server."
 
  Case 2
      GetState = "Found the IP address for the remote server."
 
  Case 3
      GetState = "Connecting to the remote server."
 
  Case 4
      GetState = "Connected to the remote server."
 
  Case 5
      GetState = "Requesting information from the remote server."
 
  Case 6
      GetState = "The request was sent successfully to the remote server."
 
  Case 7
      GetState = "Receiving a response from the remote server."
 
  Case 8
      GetState = "Удачный ответ от сервера "
 
  Case 9
      GetState = "Disconnecting from the remote server."
 
  Case 10
      GetState = "Disconnected from the remote server."
 
  Case 11
      GetState = "Ошибка при обращении к серверу."
 
  Case 12
      GetState = "The request was completed, all data has been received."
 
  Case Else
      GetState = "Unknown state: " & FormatNumber(s, 0)
 
  End Select
 
End Function


Private Sub Комманда2_Click()
Command2
End Sub
