Results 1 to 8 of 8

Thread: More questions from your noob [RESOLVED]

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    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.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  3. #3

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    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.

  4. #4

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    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

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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:
    1. If CheckedListBox1.CheckedIndices.Contains(1) Then
    2.   Msgbox("Run the Function At Index #1 or the 2nd Item on the List")
    3. 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:
    1. Dim frm As New frmAll
    2. frm.show()
    3. me.close()
    4.  
    5. 'to recreate it later
    6. Dim frm2 As New frmAll
    7. frm2.Show()
    8.  
    9. 'or if you are in a different scope you can reuse
    10. Dim frm As New frmAll
    Last edited by Edneeis; Jul 9th, 2003 at 01:40 AM.

  6. #6

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    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.

  7. #7
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    If its a regular listbox then the code is a little different but basically the same:
    VB Code:
    1. If ListBox1.SelectedIndices.Contains(1) Then
    2.   Msgbox("Run the Function At Index #1 or the 2nd Item on the List")
    3. 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.

  8. #8

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    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
  •  



Click Here to Expand Forum to Full Width