Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: phvckmeh on October 01, 2004, 02:04 AM

Title: Loading more than one instance of a form
Post by: phvckmeh on October 01, 2004, 02:04 AM
in vb6:
how to i load more than one instance of a form such as would enable me to do "whisper windows?"
Title: Re: Loading more than one instance of a form
Post by: Networks on October 01, 2004, 08:58 AM
This should be in the vb6 form.


set frmTest = new frmMain
frmTest.show


I think? I can't really remember + I don't have a vb6 open =\
Title: Re: Loading more than one instance of a form
Post by: Grok on October 01, 2004, 12:04 PM
You are correct.  To make it better, he might want named whisper windows.  Try this code for starters.


Option Explicit

Private Function FindWhisperWindow(ByVal WhisperName As String) As frmWhisper
    Dim F1 As Form
    For Each F1 In VB.Forms
        If F1.Tag = "WhisperWindow for " & WhisperName Then
            'target window found
            Set FindWhisperWindow = F1
        End If
    Next
    If FindWhisperWindow Is Nothing Then
        'did not find, need to create a new window and make it visible
        Set FindWhisperWindow = New frmWhisper
        FindWhisperWindow.Tag = "WhisperWindow for " & WhisperName
        FindWhisperWindow.Show
    End If
End Function

Private Sub Command1_Click()
    Dim WW As frmWhisper
    Set WW = FindWhisperWindow(Text1.Text)
    WW.AddChat vbWhite, "<From [vL]Grok:  This should work now>"
End Sub


Title: Re: Loading more than one instance of a form
Post by: LivedKrad on October 01, 2004, 12:08 PM
I think it's quite amazing how VB gets around itself not being an OOPL.
Title: Re: Loading more than one instance of a form
Post by: Grok on October 01, 2004, 12:27 PM
Quote from: LivedKrad on October 01, 2004, 12:08 PM
I think it's quite amazing how VB gets around itself not being an OOPL.

Realize that while VB6 may not have fully-implemented OOP features, it does have some.  Missing is inheritance and polymorphism, but VB6 is an object-BASED language, if that helps you understand.

VB.NET meanwhile, is fully OOP compliant, afaik.  MyndFyre has more experience with VB.NET and could clarify.  However, our two replies are off-topic for this forum.

And, this whole thread should be in VB programming.
Title: Re: Loading more than one instance of a form
Post by: Kp on October 01, 2004, 05:08 PM
Quote from: Grok on October 01, 2004, 12:27 PMAnd, this whole thread should be in VB programming.

Done.  On a marginally related note, could someone change phvckmeh's personal text to be something other than "Moderator"?  It looks weird, at best.