CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,898

    Resolved Dynamically Create Object Name - RESOLVED

    I think I have done this previously, but cant seem to lay my hands on how I did it.

    I have a number of forms which are named frmOrd1, frmOrd2, frmOrd3 ...... frmOrd100

    I need to be able to access any form randomly and would like to do something like this

    HTML Code:
    THIS DOES NOT WORK BUT IS WHAT I WOULD LIKE TO DO
    
    Key in a number   1-100 and allocate it to a variable   eg FormNumber
    
    then ............  
    
    
    FormName = "frmOrd" & FormNumber      'FormName might now be "frmOrd53"
    
    Load FormName
    
    Last edited by George1111; August 9th, 2023 at 11:56 PM. Reason: RESOLVED

  2. #2
    Join Date
    Aug 2003
    Location
    Sydney, Australia
    Posts
    1,898

    Resolved Re: Dynamically Create Object Name - RESOLVED

    Quote Originally Posted by George1111 View Post
    I think I have done this previously, but cant seem to lay my hands on how I did it.

    I have a number of forms which are named frmOrd1, frmOrd2, frmOrd3 ...... frmOrd100

    I need to be able to access any form randomly and would like to do something like this

    HTML Code:
    THIS DOES NOT WORK BUT IS WHAT I WOULD LIKE TO DO
    
    Key in a number   1-100 and allocate it to a variable   eg FormNumber
    
    then ............  
    
    
    FormName = "frmOrd" & FormNumber      'FormName might now be "frmOrd53"
    
    Load FormName
    

    I have an answer to the problem by ahenry in VBForums !

    Code:
        FormName = "frmOrd" & "02"
        
        Set NewForm = Forms.Add(FormName)
    
        NewForm.Show      ' Shows  frmOrd02

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured