Click here to Skip to main content
16,006,442 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralClipboardproblems = ( Pin
Anonymous27-Jul-02 0:50
Anonymous27-Jul-02 0:50 
GeneralWebBrowser Pin
Anonymous26-Jul-02 9:34
Anonymous26-Jul-02 9:34 
GeneraloverFlow... Pin
Anonymous25-Jul-02 22:08
Anonymous25-Jul-02 22:08 
GeneralRe: overFlow... Pin
SimonS25-Jul-02 23:35
SimonS25-Jul-02 23:35 
GeneralRe: overFlow... Pin
Anonymous26-Jul-02 0:25
Anonymous26-Jul-02 0:25 
GeneralRe: overFlow... Pin
SimonS26-Jul-02 2:16
SimonS26-Jul-02 2:16 
GeneralRe: overFlow... Pin
Anonymous28-Jul-02 18:07
Anonymous28-Jul-02 18:07 
GeneralVery strange stuff.. Pin
Ray Cassick25-Jul-02 20:16
Ray Cassick25-Jul-02 20:16 
Ok, I have been messing around with dynamic loading of controls now all day and have a cool example that works, but I am getting some strange results on one area.

I am trying to add a way to get messages into the control that I am loading, but I digress. Here is an example of what I have:

1) I have a control that I use as a base (Called CtlBase.BaseControl) and it is defined as such:

Public MustInherit Class BaseControl
    Inherits System.Windows.Forms.UserControl

    Public Event MessageExit(ByVal OutputMessage As String)

    Public MustOverride WriteOnly Property MessageEntry(ByVal InputMessage As String)

    Protected Sub SendEvent(ByVal EventMessage As String)

        RaiseEvent MessageExit(EventMessage)

    End Sub
End Class


I have another project that inherits from this base control declared as such:

Public Class Ctl1
    Inherits CtlBase.BaseControl

    Private Sub cmdSendEvent_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSendEvent.Click

        SendEvent(txtSendMessage.Text)

    End Sub

    Public Overrides WriteOnly Property MessageEntry(ByVal InputMessage As String)
        Set(ByVal Value)
            txtRecvdmessage.Text = Value

        End Set

    End Property
End Class


Now, I have another project that is loading the Ctrl1 dynamicaly, tieing up the event that the control exsposes (that is working fine) and trying to assign data to the WriteOnly property that the control exsposes. This app looks like such:

Imports System.Reflection

Public Class Form1
    Inherits System.Windows.Forms.Form

    Dim c As Control
    Dim m As CtlBase.BaseControl

    Private Sub cmdLoad1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdLoad1.Click

        Dim myObj As Object
        Dim myAssem As System.Reflection.Assembly

        myAssem = myAssem.LoadFrom("..\..\ControlLib\bin\ControlLib.dll")
        myObj = myAssem.CreateInstance("ControlLib.Ctl1")
        c = CType(myObj, CtlBase.BaseControl)
        c.Dock = DockStyle.Fill
        m = DirectCast(c, CtlBase.BaseControl)
        AddHandler m.MessageExit, AddressOf Ctl_Click_Handler
        pnlMainPanel.Controls.Add(c)


    End Sub

    Private Sub Ctl_Click_Handler(ByVal Message As String)

        MessageBox.Show(Message & " : Was received.")

    End Sub

    Private Sub cmdCommand_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCommand.Click

        m.MessageEntry(txtCommand.Text) = txtCommand.Text

    End Sub
End Class


The very odd thing is the way that I have to do what is listed in BOLD

If I try this as:
m.MessageEntry(txtCommand.Text)

I get a -
"I:\RUS\SnapinTest\Application\Form1.vb(155): Property 'MessageEntry' is 'WriteOnly'."

If I try it as:
m.MessageEntry = txtCommand.Text

I get a -
"I:\RUS\SnapinTest\Application\Form1.vb(155): Argument not specified for parameter 'InputMessage' of 'Public MustOverride WriteOnly Property MessageEntry(InputMessage As String) As Object'."

Can ANYONE please tell me what the hell I am doing wrong?

I mean the 'm.MessageEntry(txtCommand.Text) = txtCommand.Text' code does what I want it to, but WHY? It looks very odd to me....Confused | :confused: Confused | :confused:

HELP!!!!!OMG | :OMG:
GeneralRe: Very strange stuff.. Pin
Richard Deeming26-Jul-02 5:39
mveRichard Deeming26-Jul-02 5:39 
GeneralRe: Very strange stuff.. Pin
Ray Cassick26-Jul-02 9:07
Ray Cassick26-Jul-02 9:07 
GeneralMessage Handler in VB.NET Pin
JGraves25-Jul-02 11:11
JGraves25-Jul-02 11:11 
GeneralRe: Message Handler in VB.NET Pin
Richard Deeming26-Jul-02 5:53
mveRichard Deeming26-Jul-02 5:53 
GeneralRe: Message Handler in VB.NET Pin
JGraves26-Jul-02 8:46
JGraves26-Jul-02 8:46 
GeneralRe: Message Handler in VB.NET Pin
Richard Deeming29-Jul-02 1:21
mveRichard Deeming29-Jul-02 1:21 
GeneralRe: Message Handler in VB.NET Pin
JGraves29-Jul-02 4:18
JGraves29-Jul-02 4:18 
GeneralComboBox - MultiColumn Pin
mikasa24-Jul-02 2:52
mikasa24-Jul-02 2:52 
GeneralRe: ComboBox - MultiColumn Pin
Richard Deeming26-Jul-02 6:07
mveRichard Deeming26-Jul-02 6:07 
GeneralRe: ComboBox - MultiColumn Pin
mikasa17-Jan-03 10:03
mikasa17-Jan-03 10:03 
GeneralRe: ComboBox - MultiColumn Pin
Richard Deeming5-Aug-02 1:04
mveRichard Deeming5-Aug-02 1:04 
GeneralRe: ComboBox - MultiColumn Pin
Richard Deeming5-Aug-02 1:11
mveRichard Deeming5-Aug-02 1:11 
GeneralRe: ComboBox - MultiColumn Pin
Richard Deeming5-Aug-02 1:23
mveRichard Deeming5-Aug-02 1:23 
GeneralRe: ComboBox - MultiColumn Pin
Richard Deeming5-Aug-02 1:24
mveRichard Deeming5-Aug-02 1:24 
GeneralRe: ComboBox - MultiColumn Pin
mikasa5-Aug-02 4:41
mikasa5-Aug-02 4:41 
GeneralRe: ComboBox - MultiColumn Pin
Richard Deeming5-Aug-02 22:42
mveRichard Deeming5-Aug-02 22:42 
Generalsocket programming in vb Pin
kavitha24-Jul-02 2:22
kavitha24-Jul-02 2:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.