Results 1 to 7 of 7

Thread: Me ?

  1. #1

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

    Me ?

    What differences are between these below lines . When I used the first syntax , it's doing some kind of binding (see my last post to know about the problem) . I used that in the whole proj . When I used the second line , I never have any prpblem . What's going on ?

    VB Code:
    1. '1
    2. Me.Listbox.SelectedItem.ToString()
    3. '2
    4. Listbox.SelectedItem.ToString()

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Unless you have a shared listbox named listbox or were calling a shared method of listbox then they should be the same. By default Me is implied, so Listbox should automatically refer to the member or local listbox variable of the form. You aren't binding anything unless you set a DataSource property.

  3. #3
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    if not lazy please read this: has some important things for you:
    http://groups.google.com/groups?hl=e...8%26safe%3Doff

    Edits: Maybe we need this book:
    http://www.megabytebooks.com/catalogue/421/1590590503/
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  4. #4

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Edneeis
    Unless you have a shared listbox named listbox or were calling a shared method of listbox then they should be the same. By default Me is implied, so Listbox should automatically refer to the member or local listbox variable of the form. You aren't binding anything unless you set a DataSource property.
    I'm using the same shared method mulitple times to fill different listboxes. I used Me. keyword . I never used DataSource property within the listboxes events .

    Lunatic3 , the link is good(I've read it all) but talks about inheritance rather than using Me differences within forms but it gave me inspiration that there's a difference between the two above lines . I'll make some comparison thought !

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    So is Listbox a shared method/property of the form? If it is shared and you have an imports to where it is (if it isn't located in the form) then then wouldn't be the samething.

    VB Code:
    1. 'are NOT the same
    2.  
    3. Public Class Common 'could be a module or something else too
    4.  
    5.   Public Shared Listbox() as Listbox
    6.  
    7. End Class
    8.  
    9.  
    10. Imports Common
    11.  
    12. Public Class Form1'whatever form you are in
    13.  
    14.    Dim Listbox As New ListBox 'or refer to one on form
    15.  
    16.    'inside a method
    17.     Msgbox(Me.Listbox.SelectedItem.ToString) 'will reference the local listbox declared in this form
    18.  
    19.     Msgbox(Listbox.SelectedItem.ToString) 'will reference the shared listbox from the Common Class since Common is imported
    20.  
    21. End Class

    VB Code:
    1. 'ARE the same
    2.  
    3. Public Class Form1'whatever form you are in
    4.  
    5.    Dim Listbox As New ListBox 'or refer to one on form
    6.  
    7.    'inside a method
    8.     Msgbox(Me.Listbox.SelectedItem.ToString) 'will reference the local listbox declared in this form
    9.  
    10.     Msgbox(Listbox.SelectedItem.ToString) 'will reference the local listbox since it defaults to the local level or form
    11. End Class

  6. #6

    Thread Starter
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    'In class file :
    VB Code:
    1. Public Shared Sub SearchDB(ByVal SearchText As String, ByVal TableStr As String, ByVal colum As String, ByVal LstBox As ListBox)
    2. '
    3. '
    4. '
    5. LstBox.DataSource = dv
    6. LstBox.DisplayMember = colum
    7. ds = Nothing
    8. dv = Nothing
    9. End Sub


    Imported within Form1 as follow :
    VB Code:
    1. Imports ProgramsStore.Class1

    used like this :

    VB Code:
    1. SearchDB(S_Comb_Crack.SelectedItem.ToString, "MyTab", "C_Crack", ListBox1)

    I repeat , the function is well-working (this is the third time I use it) . I used the same implementation in all my project and worked just fine but not this ******* .
    Can you see anything wrong here guys !

  7. #7
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    The keyword Me exists for clarity and also to allow the developer to pass a reference to the current object as a parameter to methods in other objects.

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