Using class Inet in a non form application

How can I use the class Inet in a non form application. I'm getting an initializate error when I try to using the object Inet
The code is:

Dim conexion As InetCtlsObjects.Inet
Dim StrHttp As String
With conexion
.URL = StrHttp
.OpenURL(StrHttp, icString)
End With

TIA & Best Regards
Paco

Comments

  • : How can I use the class Inet in a non form application. I'm getting an initializate error when I try to using the object Inet
    : The code is:
    :
    : Dim conexion As InetCtlsObjects.Inet
    : Dim StrHttp As String
    [b]Set conexion = New InetCtlsObjects.Inet[/b]
    : With conexion
    : .URL = StrHttp
    : .OpenURL(StrHttp, icString)
    : End With
    :
    : TIA & Best Regards
    : Paco
  • : Dim conexion As InetCtlsObjects.Inet
    : Dim StrHttp As String
    : [b]Set conexion = New InetCtlsObjects.Inet[/b]
    Wrrrrrr :-(

    For more than few months I was trying to use a control without any Form, and I know the New operator can be used in Dim (for declaring classes) but = New ? I see there are still many things I have to learn.
  • : : Dim conexion As InetCtlsObjects.Inet
    : : Dim StrHttp As String
    : : [b]Set conexion = New InetCtlsObjects.Inet[/b]
    : Wrrrrrr :-(
    :
    : For more than few months I was trying to use a control without any Form, and I know the New operator can be used in Dim (for declaring classes) but = New ? I see there are still many things I have to learn.
    :

    Dim conexion As New InetCtlsObjects.Inet

    While that could work, I've heard it leads to bad programming practices. It has to do with that fact that if you attempt to use the object (in this case conexion) and it's not currently set, VB will set it for you. On the other hand, if you do it the way I posted, you know when your code is accessing an object that is supposed to be empty (you've not set it yet or have set it to nothing). Makes it easier to remember to clean up after yourself (Set conexion = Nothing) if you have to specifically instantiate each object.

    In summary, "Dim As New" works, but try to use "Dim As" and "Set = New".

    KDL
  • : : : Dim conexion As InetCtlsObjects.Inet
    : : : Dim StrHttp As String
    : : : [b]Set conexion = New InetCtlsObjects.Inet[/b]
    : : Wrrrrrr :-(
    : :
    : : For more than few months I was trying to use a control without any Form, and I know the New operator can be used in Dim (for declaring classes) but = New ? I see there are still many things I have to learn.
    : :
    :
    : Dim conexion As New InetCtlsObjects.Inet
    :
    : While that could work, I've heard it leads to bad programming practices. It has to do with that fact that if you attempt to use the object (in this case conexion) and it's not currently set, VB will set it for you. On the other hand, if you do it the way I posted, you know when your code is accessing an object that is supposed to be empty (you've not set it yet or have set it to nothing). Makes it easier to remember to clean up after yourself (Set conexion = Nothing) if you have to specifically instantiate each object.
    :
    : In summary, "Dim As New" works, but try to use "Dim As" and "Set = New".
    :
    : KDL
    :

    It works fine,
    very thanks
    Pako

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories