Results 1 to 8 of 8

Thread: How can i do this

  1. #1

  2. #2
    Addicted Member
    Join Date
    Nov 2003
    Location
    India
    Posts
    227
    Yes of course.

    In that class write a function which accepts the Test & the referenced label as an argument. Call the function whenever u needed. Make sure to pass by refernce. But I think this is waste of time.
    See you,
    -Jai
    [Friends Never Say Good Bye]

  3. #3
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    If you wanted to keep the UI out of your class you could also fire off an event that your form is subscribed to. Then the form could change the text when the event is handled.

  4. #4

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    VB Code:
    1. Public Class Example
    2.  
    3.    Public Shared Sub SetText(ByVal lbl As Label, ByVal text As String)
    4.       lbl.Text=text
    5.    End Sub
    6.  
    7. End Class
    8.  
    9. 'syntax
    10. Example.SetText(Label1,"Some Text")

  6. #6
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    VB Code:
    1. 'Code In Class
    2.  
    3. Public Class cSampleClass
    4.  
    5.     Public Event InfoForTextbox(ByVal strInfo As String)
    6.  
    7.  
    8.     Public Function DoSomething()
    9.         '.....
    10.  
    11.         RaiseEvent InfoForTextbox("Hello")
    12.  
    13.         '.....
    14.     End Function
    15.  
    16. End Class

    VB Code:
    1. Public Class Form1
    2.     Inherits System.Windows.Forms.Form
    3.  
    4.     WithEvents cSample As cSampleClass
    5.  
    6. '|| form designer code here
    7.  
    8.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    9.         cSample.DoSomething()
    10.     End Sub
    11.  
    12.     Private Sub CalledWhenInfoIsPassed(ByVal strInfo As String) Handles cSample.InfoForTextbox
    13.         LabelName.Caption = strInfo
    14.     End Sub
    15. End Class
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  7. #7

  8. #8
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I don't think you can use WithEvents with an array still, so you'[d have to add each new instance using the AddHandler instead of WithEvents.

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