|
-
May 9th, 2003, 02:52 PM
#1
Thread Starter
Sleep mode
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
Me.Listbox.SelectedItem.ToString()
'2
Listbox.SelectedItem.ToString()
-
May 9th, 2003, 03:12 PM
#2
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.
-
May 9th, 2003, 03:15 PM
#3
Frenzied Member
'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
-
May 9th, 2003, 03:37 PM
#4
Thread Starter
Sleep mode
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 !
-
May 9th, 2003, 03:51 PM
#5
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:
'are NOT the same
Public Class Common 'could be a module or something else too
Public Shared Listbox() as Listbox
End Class
Imports Common
Public Class Form1'whatever form you are in
Dim Listbox As New ListBox 'or refer to one on form
'inside a method
Msgbox(Me.Listbox.SelectedItem.ToString) 'will reference the local listbox declared in this form
Msgbox(Listbox.SelectedItem.ToString) 'will reference the shared listbox from the Common Class since Common is imported
End Class
VB Code:
'ARE the same
Public Class Form1'whatever form you are in
Dim Listbox As New ListBox 'or refer to one on form
'inside a method
Msgbox(Me.Listbox.SelectedItem.ToString) 'will reference the local listbox declared in this form
Msgbox(Listbox.SelectedItem.ToString) 'will reference the local listbox since it defaults to the local level or form
End Class
-
May 9th, 2003, 04:08 PM
#6
Thread Starter
Sleep mode
'In class file :
VB Code:
Public Shared Sub SearchDB(ByVal SearchText As String, ByVal TableStr As String, ByVal colum As String, ByVal LstBox As ListBox)
'
'
'
LstBox.DataSource = dv
LstBox.DisplayMember = colum
ds = Nothing
dv = Nothing
End Sub
Imported within Form1 as follow :
VB Code:
Imports ProgramsStore.Class1
used like this :
VB Code:
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 !
-
May 9th, 2003, 04:11 PM
#7
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|