Help with "My" functions!

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Thread Solved

Join Date: Oct 2006
Posts: 3
Reputation: learnerd is an unknown quantity at this point 
Solved Threads: 0
learnerd learnerd is offline Offline
Newbie Poster

Help with "My" functions!

 
0
  #1
Oct 18th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 188
Reputation: aparnesh is an unknown quantity at this point 
Solved Threads: 10
aparnesh's Avatar
aparnesh aparnesh is offline Offline
Junior Poster

Re: Help with "My" functions!

 
0
  #2
Oct 18th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 3
Reputation: learnerd is an unknown quantity at this point 
Solved Threads: 0
learnerd learnerd is offline Offline
Newbie Poster

Re: Help with "My" functions!

 
0
  #3
Oct 18th, 2006
There is such object, it is listed in the MSDN
http://msdn2.microsoft.com/en-us/library/11bxex12.aspx
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 3
Reputation: bpmccall is an unknown quantity at this point 
Solved Threads: 1
bpmccall bpmccall is offline Offline
Newbie Poster

Re: Help with "My" functions!

 
0
  #4
Oct 18th, 2006
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 3
Reputation: learnerd is an unknown quantity at this point 
Solved Threads: 0
learnerd learnerd is offline Offline
Newbie Poster

Re: Help with "My" functions!

 
0
  #5
Oct 18th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC