VB School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB Expert!

Join 300,489 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,810 people online right now. Registration is fast and FREE... Join Now!




DYNAMIC OBJECT REFERENCES IN FUNCTION

 

DYNAMIC OBJECT REFERENCES IN FUNCTION, I WANT TO MAKE A REFERENCE TO AN OBJECT IN THE FORM WHOSE NAME IS FORM

PAPPULLY65

16 Jul, 2008 - 12:54 AM
Post #1

New D.I.C Head
*

Joined: 16 Jul, 2008
Posts: 1

CODE
Function FNDUPPER(MLEV As Integer) As Boolean
FNDUPPER = False
'MLEV = Len(CURCMD(Index).Name) - 6

For I = 0 To UBound(NOBJL)
    If NOBJL(I) > MLEV Then
       NLOBJ(I).Visible = False
       NOBJL(I) = -1
       FNDUPPER = FINDOBJECT("MCMD" & MLEV)
       Set NLOBJ(I) = Nothing
    End If
Next
End Function


Function FINDOBJECT(ByVal OBJNAME As Object) As Boolean
For J = 0 To OBJNAME.UBound
    If OBJNAME(J).Visible = False Then FINDOBJECT = False: Exit For
Next
End Function


User is offlineProfile CardPM
+Quote Post


PsychoCoder

RE: DYNAMIC OBJECT REFERENCES IN FUNCTION

18 Jul, 2008 - 11:35 AM
Post #2

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
You you please post your question in the body of your post and not in the topic description. The description field holds a very limited number of characters. Also typing in all CAPS is considered yelling smile.gif
User is offlineProfile CardPM
+Quote Post

Ken Halter

RE: DYNAMIC OBJECT REFERENCES IN FUNCTION

23 Jul, 2008 - 05:23 PM
Post #3

New D.I.C Head
*

Joined: 18 Nov, 2007
Posts: 35



Thanked: 11 times
My Contributions
Agreeing with PsychoCoder here... your question didn't make it thru and stop yelling! ;-)

But... and it's hard to tell going by the code you posted... there doesn't seem to be a need to know the name of the form.... not using the code you posted anyway (which can most likely be simplified)

If you repost the question, try and include more details, too... like... those arrays you're working with appear to be control arrays, but knowing that as a fact can make a big difference in the answer you end up getting.
User is offlineProfile CardPM
+Quote Post

kikz

RE: DYNAMIC OBJECT REFERENCES IN FUNCTION

23 Jul, 2008 - 06:18 PM
Post #4

New D.I.C Head
*

Joined: 21 Jul, 2008
Posts: 32



Thanked: 2 times
My Contributions
A bit more information is needed to clearly answer your question. In lieu of that information I'll make a few guesses. wink2.gif

What sort of objects are you talking about? Controls on the form?
Do you mean COM objects?

What is NOBJL() an array of? It's not declared within your code snippet.


If you're looking for a control object on a form, you can interate through the form's control collection until you find a match on name
CODE

Function FindControl(frm as Form, sControlName as String) as Boolean
  FindControl = False

  Dim ctrl as Control
  For Each ctrl In frm.Controls
    If ctrl.Name = sControlName Then
      FindControl = True
      Exit For
    End If
  Next ctrl

End Function


(I think that will also iterate over the controls in container controls? If not, just do a bit of recursion inside the FindControl function.)

This post has been edited by kikz: 23 Jul, 2008 - 06:19 PM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 04:14AM

Live VB Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month