|
-
Jul 7th, 2003, 08:17 PM
#1
More questions from your noob [RESOLVED]
1. I have a dialog box that opens up. It't another form and I open it with
frmAll.show()
It's declared as a new form already but It works fine and I can open it, but the exit button in the dialog does a me.close()
When I try to open it again, I get an error saying something about "Object already terminated". How can I keep re-opening it? Should I hide instead of closing it or something?
2.I have functions I want to run if certain boxes are checked. I use some code to check all the boxes or the selected boxes but when the user hits apply, how can I make it so only certain functions are run? Like is there a
if listitem(1).selected then
'do stuff
??
3. Last question. Is there anyway to make a VB .NET program not require the .NET framework? Like can't it compile it down to native code instead of .NET code?
Thats all
Last edited by Kasracer; Jul 9th, 2003 at 03:08 PM.
-
Jul 7th, 2003, 11:47 PM
#2
1) Post your code for initializing or loading the form.
2) Yes you can check each item if it is selected or not. I don't think a listbox will give the items a selected property but you can see if they are in the SelectedItems collection. If ListBox1.SelectedItems.IndexOf(Listbox1.Item(0))>-1 Then...
3) No there is no way around this you MUST have the .NET framework.
-
Jul 8th, 2003, 01:08 AM
#3
Originally posted by Edneeis
1) Post your code for initializing or loading the form.
2) Yes you can check each item if it is selected or not. I don't think a listbox will give the items a selected property but you can see if they are in the SelectedItems collection. If ListBox1.SelectedItems.IndexOf(Listbox1.Item(0))>-1 Then...
3) No there is no way around this you MUST have the .NET framework.
1. Dim frmAll As New frmAll
Then open with frmAll.show()
Close with me.close()
I realize this destroys the object and cannot re-create it, so I'm using hide() which works fine cause it's a form that may need ot be called hidden and called again.
2. So it will give me an index of the selected? So if I have a 10 item list and 5 are selected, it will return an index 1-5? If so, how the hell would I know what's being used so I know what functions to call?
3. I figured that, but I heard someone saying you could have it compile to native code so it would work on something other than .NET. You'd think MS would of made the .NET more like a library than a framework. If they would of made it a library, file sizes would be a little larger but you would be able to run it on any windows platform like C++ code. It would be like using the .NET framework but not requiring it! Ugh MS pisses me off, it's like they don't want VB programs to get distributed.
-
Jul 8th, 2003, 02:37 PM
#4
1. RESOLVED
2. Need help still, I can't figure out how to tell what has been selected especially fi I have to re-index cause I can't go off numbers then
3. I guess resolved..... eh
-
Jul 9th, 2003, 01:36 AM
#5
You should explain more about your problem or the situation in your posts, you'll get more answers that way. No offense meant.
Are you using a Listbox, CheckedListBox, or some Checkboxes? I'm guessing a CheckedListBox, if so then it should look something like this:
VB Code:
If CheckedListBox1.CheckedIndices.Contains(1) Then
Msgbox("Run the Function At Index #1 or the 2nd Item on the List")
End If
If you wanted to avoid a bunch of If..Then statements you could use Delegates and store the functions (or a delegate pointing to them) in the actual ListBox item itself and run it.
Also regarding #1, if you close a form you can still recreate it later if you want. One thing that may be getting you confused or messing with your code is using the type name as the name of the instance. This can be done but then it can get confusing when you are working with a shared member or an instance member and should be avoided. In other words if the form type is frmAll then you shouldn't call the variable with an instance of it frmAll.
VB Code:
Dim frm As New frmAll
frm.show()
me.close()
'to recreate it later
Dim frm2 As New frmAll
frm2.Show()
'or if you are in a different scope you can reuse
Dim frm As New frmAll
Last edited by Edneeis; Jul 9th, 2003 at 01:40 AM.
-
Jul 9th, 2003, 02:12 PM
#6
Originally posted by Edneeis
Are you using a Listbox, CheckedListBox, or some Checkboxes? I'm guessing a CheckedListBox, if so then it should look something like this:
I'm using a list box. I have a list of like 12 items. Each item I want to have a function associated with itso if someone checks item #ed 5-10, they will run the functions that correspond to #5-10 when the user clicks apply.
-
Jul 9th, 2003, 02:26 PM
#7
If its a regular listbox then the code is a little different but basically the same:
VB Code:
If ListBox1.SelectedIndices.Contains(1) Then
Msgbox("Run the Function At Index #1 or the 2nd Item on the List")
End If
Or if you wanted to get technical you could create a class that holds a delegate and a title and fill the listbox with those. Then run the delegate for all the selected items.
-
Jul 9th, 2003, 03:09 PM
#8
THANKS!
Works perfectly
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
|