944,202 Members | Top Members by Rank

Ad:
Oct 18th, 2006
0

Help with "My" functions!

Expand Post »
Hi, I am trying to use the "My" functions in Visual basic, but every time i run the code, it give me a Runtime error 424 - object required.
I am a newbie at this, please help.
I don't have anything else in the code, just New Project, Stantard EXE project, then in the Form1, i have this code

Private Sub Form_Load()
MsgBox ("Computer name: " & My.Computer.Name)
End Sub

When i run, it give me the error, I think i have to do something first before i use the My.Computer.Name, but i don't know what, i tried search MSDN but can't find the steps on how to use it. Thanks for the help.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
learnerd is offline Offline
3 posts
since Oct 2006
Oct 18th, 2006
0

Re: Help with "My" functions!

What is "My" ? As far as I know there is no in-built VB object called "My". If you are trying to use an object you created then you have to include the reference to that object.
For example If you have created an object called myObject which has a property called ComputerName then the code should be like
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Dim my as new myObject
  2. Msgbox my.ComputerName
Reputation Points: 20
Solved Threads: 10
Junior Poster
aparnesh is offline Offline
193 posts
since Jul 2005
Oct 18th, 2006
0

Re: Help with "My" functions!

There is such object, it is listed in the MSDN
http://msdn2.microsoft.com/en-us/library/11bxex12.aspx
Reputation Points: 10
Solved Threads: 0
Newbie Poster
learnerd is offline Offline
3 posts
since Oct 2006
Oct 18th, 2006
0

Re: Help with "My" functions!

I think what you may be referring to is actually called "Me". "Me", like "this" in C++, is a reference to the object for which you are creating code. You are placing code in a form object, so "Me" is a reference to that form. Forms contain methods and procedures which can be accessed by Me.methodName() or Me.propertyName. This is redundant, however, because "Me" is assumed. Furthermore, "Computer" is not one of the properties or methods contained in a Form. If you are just starting out, I'd suggest finding a tutorial web site or buy a book.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
bpmccall is offline Offline
3 posts
since Oct 2006
Oct 18th, 2006
0

Re: Help with "My" functions!

I found out what the problem is, the "My" function is only supported in the .net versions, not vb6 and below. Thanks for the help guys.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
learnerd is offline Offline
3 posts
since Oct 2006

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Single-server, multiple client ActiveX
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: SQL Biblio.mdb database





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC