We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

Object Reuired .. HELP PLS newbie here

Medium Priority
186 Views
Last Modified: 2013-11-13
Hello .. i am a newbie at VB6.0

i run my application and i click the button and receive this error

--------------------
Run-time error 424:

Object Required
----------------------

Help plss!!
Comment
Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
can you post the code on the click button?

this is simply an object variable that got not initalizd

Author

Commented:
yes
Brian MulderFreelance
Top Expert 2006

Commented:
Hello KingSencat,

better post a bit of your code, this error happens when you try to work with an object that is not initialized

bruintje

Author

Commented:
Private Sub Command1_Click()
    'This is your button code that connects to the webpage
    Winsock1.Close
    Winsock1.Connect "http://www.yourwebpage.com", 80
End Sub

Private Sub Winsock1_Connect()
    'The control is now connected, request the webpage
    Winsock1.SendData "GET /yourpage.php HTTP/1.1" & vbCrLf & vbCrLf
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    'This sub will be called when the server is sending data
    'Declare Vars
    Dim strData As String
    '
    'Retrieve the data
    Winsock1.GetData strData
    '
    'And just for you: output the data, this will show you the HTML code of the page
    'You can remove this
    Debug.Print strData
End Sub
Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
does the winsock control that you have on the form really the name Winsock1 ?

let me assume that you do NOT have the following in front of all your modules:

OPTION EXPLICIT

you should also enable the "Require Variable Declaration" option in the options of VB

Author

Commented:
Can you give me the working source please ? .. i am newbie at VB6.0
Guy Hengel [angelIII / a3]Billing Engineer
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2009

Commented:
There is a question I asked you: Is there a control with the name "Winsock1" on your form?

Note: as you are a newbie, you should follow the advice I gave you about the option explicit.

if you answer with YES the question, have set the option explicit, can you try to compile the project.
I am SURE the project does NOT compile.

Author

Commented:
This what i paste before its all the source ...  the Winsock1 name is only in the source  ... i enable  "Require Variable Declaration" .. and stil lsame problem
Brian MulderFreelance
Top Expert 2006

Commented:
>>the Winsock1 name is only in the source
you need to add a winsock control to the form

which is doen in this sample
source: http://www.vbip.com/winsock/winsock_whois.asp

Author

Commented:
can you copy and paste here what i must to put at my source?
Brian MulderFreelance
Top Expert 2006

Commented:
no because if you did not put a control on your form you really have to do it yourself

1. In your vb IDE rightclick on the component tab
2. then click on components
3. look for the microsoft winsock control
4. check the box in front of it and it will be added to the component tab
5. now drag it to your form
6. that will enable you to work with winsock1 in your code

Author

Commented:
I dont understand what you mean -->" IDE" ... my english not so good ..

Author

Commented:
Component MSWINSCK.OCX not correctly registered
Brian MulderFreelance
Top Expert 2006

Commented:
ok can describe what you did?

. IDE is the VB environment where you place your form etc....

>> Component MSWINSCK.OCX not correctly registered

when does that happen?

Author

Commented:
ok i dont see any errors now ... but its not connecting to the site
Freelance
Top Expert 2006
Commented:
this worked for me

Option Explicit

Private Sub Command1_Click()
    'This is your button code that connects to the webpage
    Winsock1.Close
    Winsock1.RemoteHost = "experts-exchange.com"
    Winsock1.RemotePort = 80
    Winsock1.Connect
End Sub

Private Sub Winsock1_Connect()
    'The control is now connected, request the webpage
    Winsock1.SendData "GET /Programming/Programming_Platforms/Win_Prog/Q_21795925.html HTTP/1.1" & vbCrLf & vbCrLf
End Sub

Private Sub Winsock1_DataArrival(ByVal bytesTotal As Long)
    'This sub will be called when the server is sending data
    'Declare Vars
    Dim strData As String
    '
    Winsock1.GetData strData, vbString
    Winsock1.Close

    '
    'And just for you: output the data, this will show you the HTML code of the page
    'You can remove this
    Debug.Print strData
End Sub

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
You have forgotten to add the Microsoft Winsock Control.

To do so:

Right click on the left side of your dev environment, click on "Components...", then checkmark "Microsoft Winsock Control".

If you are actually COPYING your compiled .exe to another computer, you ALSO need to copy the winsock control (*.ocx) to that system. When you click on components, you will see what it is called and where. (I.e., MSWINSCK.OCX).
Brian MulderFreelance
Top Expert 2006

Commented:
though i believe my last comment answered the question, it probably was also answered here which i didn't see at the time

http://www.experts-exchange.com/Q_21796453.html
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.