Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB Inet Control

Posted on 2003-11-06
11
Medium Priority
?
2,119 Views
Last Modified: 2013-12-26
Hi everyone, I'm new  to VB world! I am using a simple Inet Control and the syntax is below
response = Inet1.OpenURL(URL, icString)
             MsgBox (response)

but somehow it doesn't connect to the URL
Do I need to set up something or activate the control or something?
any idea?

thanks
0
Comment
Question by:Majusri
  • 5
  • 4
  • 2
11 Comments
 
LVL 9

Expert Comment

by:Dang123
ID: 9695477
Try this

    response = Inet1.OpenURL(URL, icString)
    Do While Inet1.StillExecuting
        DoEvents
    Loop
    MsgBox (response)


Dang123
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9695518
Majusri,
    It takes a little time to establish the connection and return the contents of the page you are requesting. The loop will allow your program to wait for the page to be returned. You could also put code into the StateChanged event for the control. That would prevent you from using CPU cycles in a wait loop. The method you pick would depend on what you want to accomplish.

Dang123
0
 

Author Comment

by:Majusri
ID: 9715156
well it not really working! I implement this peice of code

Do While Inet1.StillExecuting
                DoEvents
             Loop

but it giving me the error :
Gopher - Attribute not found
the error code is 12057

it seem like sometime it work and most of the time it given this error. Anyone know why?

Majusri
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Accepted Solution

by:
Dang123 earned 100 total points
ID: 9715201
Majusri,
Can you post your full form that is giving you trouble?

1. Start notepad.
2. File -> Open
3. Find the .frm file containing your form.
4. Change any sensitive information - passwords or ids to something else
5. Select all the text
6. Copy it and paste it into the comment box here.

(** Remember do NOT save the file if you changed anything in step 4 **)

Dang123
0
 

Author Comment

by:Majusri
ID: 9715248
VERSION 5.00
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form uploadFile
   Caption         =   "uploadForm"
   ClientHeight    =   6645
   ClientLeft      =   3435
   ClientTop       =   3030
   ClientWidth     =   11100
   Icon            =   "uploadFile.frx":0000
   ScaleHeight     =   6645
   ScaleWidth      =   11100
   Begin InetCtlsObjects.Inet Inet1
      Left            =   4080
      Top             =   2040
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
      Protocol        =   5
      RemotePort      =   443
      URL             =   "https://"
   End
   Begin VB.CommandButton Command1
      Caption         =   "upload now!"
      Height          =   495
      Left            =   3720
      TabIndex        =   0
      Top             =   1320
      Width           =   1215
   End
End
Attribute VB_Name = "uploadFile"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
ListFile "F:/"
End Sub
Public Sub ListFile(ByVal DirName As String)

Dim filesys As Object
Dim txtStream As Object
Dim files
Dim fileName
Dim File
Dim strXML As String
Dim URL As String
Dim folder
Dim response As String
Dim fileLoad As String
Dim pass As String


 On Error Resume Next
    If (Dir$(DirName, vbDirectory) = "") Then Exit Sub
    Set filesys = CreateObject("Scripting.FileSystemObject")
    Set folder = filesys.GetFolder(DirName)
 
     Set files = folder.files
       If files.Count <> 0 Then

      For Each File In files
       Set f = filesys.GetFile(File)
       Set txtStream = filesys.openTextFile(f)
       setFileName = f.Name

            If Not txtStream.AtEndOfStream Then
               Do While Not txtStream.AtEndOfStream
                  strXML = strXML + txtStream.readline
               Loop
            End If
             URL = "https://localhost/getXML.asp?filename=" & setFileName & "&" & "XML=" & strXML
             
             Inet1.Cancel
             Inet1.Protocol = icHTTPS
             Inet1.AccessType = icDirect
             Inet1.URL = URL
             response = Inet1.OpenURL(URL, icString)
             
             Loop
            fileLoad = fileLoad + response
             strXML = Clear
             DoEvents
           
    Next
 End If
 MsgBox (fileLoad)
 
End Sub




Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim status As String
Select Case State


  Case icError
 
    MsgBox (Inet1.ResponseCode & "   " & Inet1.ResponseInfo)
 
End Select


End Sub
0
 

Author Comment

by:Majusri
ID: 9715297
ignore the Loop after the Inet1.OpenURL
 
0
 

Author Comment

by:Majusri
ID: 9715948
does anyone know why did I get this error

error code: 12057
error message: Gopher - Attribute not found
0
 
LVL 9

Expert Comment

by:Dang123
ID: 9716652
Majusri,
    Were you able to solve the 12057 error? I was still looking at the code you posted above. I don't have a server I can test it against, so it was taking a bit longer.

    By the way, if you have line breaks in your XML files, I think you may have a problem with them since you are passing them in your URL. Also since a URL has a maximum length of 2,083 I was also considering that if your files are large it may be causing problems also.

Dang123


0
 

Author Comment

by:Majusri
ID: 9717036
Thanks Dang123!
 
   The problem being is the Revocation List(SSL) is not available therefore the Inet Control throws that error. I have clue why is that but I have tried a different server and it working quite well. So thank alot for your help.

Majusri - VanThu
0
 

Expert Comment

by:aramos_Takion
ID: 37850176
Hi,  

Could I ask how did you fix the issue?  I have the same problem in a similar environment
Error 11 Gopher Attribute not found

Many thanks
Antonio
0
 

Expert Comment

by:aramos_Takion
ID: 37850193
This is my code:

VERSION 5.00
Object = "{48E59290-9880-11CF-9754-00AA00C00908}#1.0#0"; "MSINET.OCX"
Begin VB.Form frmRecu
   BorderStyle     =   1  'Fixed Single
   ClientHeight    =   615
   ClientLeft      =   15
   ClientTop       =   15
   ClientWidth     =   1200
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   615
   ScaleWidth      =   1200
   StartUpPosition =   3  'Windows Default
   Begin VB.Timer timMaxEspera
      Left            =   630
      Top             =   0
   End
   Begin InetCtlsObjects.Inet InetRecPub
      Left            =   45
      Top             =   0
      _ExtentX        =   1005
      _ExtentY        =   1005
      _Version        =   393216
   End
End
Attribute VB_Name = "frmRecu"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' DTA (RT)
Private blnDatosRecibido As Boolean
Private strDatosEnt As String
Private mlngInterval As Long
Private Sub ActivaTemporizador()
 
  On Error GoTo errActivaTemporizador
 
  If mlngInterval <> 0 Then timMaxEspera.Enabled = True
 
errActivaTemporizador:

  If Err.Number <> 0 Then
    strMsgError = "Error al inicializadar el temporizador"
  End If
End Sub
Public Property Let MaxTmpEspera(ByVal lngMaxTmp As Long)
 
  On Error GoTo errMaxTmpEspera
 
  lngMaxTmp = lngMaxTmp * 1000
  If lngMaxTmp < 1 And lngMaxTmp > 60000 Then
    strMsgError = "[ComPetHTTP:frmRecu:MaxTmpEspera] Se estableció un tiempo de espera incorrecto " & lngMaxTmp
    mlngInterval = 0
  Else
    timMaxEspera.Interval = lngMaxTmp
    mlngInterval = lngMaxTmp
  End If
 
errMaxTmpEspera:

  If Err.Number Then
    strMsgError = "Error al establecer el tiempo máximo de espera " & lngMaxTmp
  End If

End Property

Public Function RecContURL(ByRef stCont As String, ByVal stUrl As String, _
                           Optional ByVal stPuerto As String) As Boolean
                           
  On Error GoTo errRecContURL
 
  With InetRecPub
    ' Le estoy estableciendo el tiempo maximo de espera
    .RequestTimeout = 15
    .Protocol = icHTTP
    If stPuerto <> "" Then .RemotePort = stPuerto
    .URL = stUrl
    stCont = .OpenURL()
  End With
  RecContURL = True
 
errRecContURL:
 
 If Err.Number <> 0 Then
    stCont = Err.Description
    RecContURL = False
 End If

End Function

Public Function SendDataUrl(ByRef strDatResp As String, ByRef arrDatos() As String, _
                            ByVal strURL As String, ByVal strPuerto As String) As Boolean
 
  Dim strDAtos As String
  Dim lngCampo As Long
 
  On Error GoTo errRecContURL
 
  For lngCampo = 0 To UBound(arrDatos) Step 2
    If strDAtos <> "" Then strDAtos = strDAtos & "&"
    strDAtos = strDAtos & arrDatos(lngCampo) & "=" & arrDatos(lngCampo + 1)
  Next lngCampo
 
 
  With InetRecPub
   .RequestTimeout = 15
   .Protocol = icHTTPS 'icHTTP
   If strPuerto <> "" Then .RemotePort = strPuerto
   blnDatosRecibido = False
   .Execute strURL, "POST", strDAtos, "Content-Type: application/x-www-form-urlencoded"
   ActivaTemporizador
   
   Do While Not blnDatosRecibido And strMsgError = ""
    DoEvents
   Loop
   
   If blnDatosRecibido And strMsgError = "" Then
    strDatResp = strDatosEnt
    SendDataUrl = True
   End If
  End With
   
errRecContURL:
 
 If Err.Number <> 0 Then
   If strMsgError = "" Then
        strMsgError = "[ComPetHttp: SendDataUrl] Error(" & Err.Description & ")" & _
                  "Cadena:" & Join(arrDatos, "#$#")
    End If
    SendDataUrl = False
 End If
   
End Function

Private Sub Form_Load()
  blnFormLoad = True
  mlngInterval = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
  blnFormLoad = False
End Sub

Private Sub InetRecPub_StateChanged(ByVal State As Integer)
  ' Cuando termine correctamente, recuperaré los datos devueltos por la página
  Dim strBloqDat As String
 
  On Error GoTo errInetRecPub_StateChanged
 
  Select Case State
    Case icResponseCompleted
      strBloqDat = InetRecPub.GetChunk(1024, icString)
      Do While strBloqDat <> ""
        strDatosEnt = strDatosEnt & strBloqDat
        strBloqDat = InetRecPub.GetChunk(1024, icString)
      Loop
      blnDatosRecibido = True
      timMaxEspera.Enabled = False
    Case icError
      strMsgError = "No se pudo conectar con el servidor especificado " & InetRecPub.ResponseInfo
     
  End Select

errInetRecPub_StateChanged:
 
  If Err.Number <> 0 Then
    If strMsgError = "" Then strMsgError = "Error en InetRecPub_StateChanged(" & _
                                           Err.Description & ")"
  End If
End Sub

Private Sub timMaxEspera_Timer()
  strMsgError = "Agotado el tiempo maximo de espera"
  lngErr = 10001
  timMaxEspera.Enabled = False
End Sub
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question