Results 1 to 11 of 11

Thread: Again problem (a little) with ComboBox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Again problem (a little) with ComboBox

    Hi All

    What I will be more of tells, please, you have a look alone
    VB Code:
    1. Option Explicit
    2. Dim intNoFile As Integer
    3.  
    4. Private Sub cmdSave_Click()
    5. '>>> Save the Combo1 items to a text file
    6.    
    7.     Dim i As Integer
    8.     '>>> Get the next free file
    9.     intNoFile = FreeFile
    10.     Open "C:\MyFile.dat" For Append As #intNoFile
    11.    
    12.     '>>> Obviously it's a loop For..Next
    13.     For i = 0 To Combo1.ListCount - 1
    14.     '>>> Add to the file every line from the Combo1
    15.     Print #intNoFile, Combo1.List(i)
    16.     Next i
    17.     Close #intNoFile
    18.    
    19. End Sub
    20.  
    21. Private Sub cmdOpen_Click()
    22.  
    23.     Dim str As String
    24.    
    25.     Combo1.Clear  '>>> As everybody knows
    26.     intNoFile = FreeFile
    27.    
    28.     Open "C:\MYFile.dat" For Input As intNoFile
    29.    
    30.     Do While Not EOF(intNoFile)    '>>> Again this loop
    31.         Line Input #intNoFile, str   '>>> Fact, a bit other
    32.         Combo1.AddItem str
    33.     Loop
    34.    
    35.     Close intNoFile
    36. End Sub

    Here's this my problem, my quest it is:
    How to make to add from Combo1 to.... Combo1?

    VB Code:
    1. Private Sub cmdAddToCombo_Click()
    2.  
    3. '>>> it don't works
    4. Combo1.AddItem Combo1.ListCount - 1
    5.  
    6. '>>> But it fine works, when I have such code like below
    7. Combo1.AddItem Text1.Text
    8.  
    9. End Sub
    I tried to add with this list again first an item (with index - 1). If this was a successful it this first thing should again find oneself on list in lately position

    I want to be able it add at this Combo1 control. It is possible?
    thanks in advance for each reply
    Last edited by Tamgovb; Apr 30th, 2006 at 05:42 PM.
    I know, I know, my English is bad, sorry .....

  2. #2

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: Again problem (a little) with ComboBox

    Quote Originally Posted by Tamgovb
    ...How to make to add from Combo1 to.... Combo1?
    Each listitem returns string type so when you do some like

    Combo1.AddItem Combo1.ListCount - 1

    you're simply adding new item with its text equal to INDEX of the LAST ITEM in your combobox.

    My question to you is: what do you want to be added?

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Re: Again problem (a little) with ComboBox

    thanks for quick reply.
    Orginally posted by MartinLiss:
    Is that what you want to do?
    Hmm, good question. I want to simplify the record of code as well as works of project


    Orginally posted by RhinoBull:
    what do you want to be added?
    The new of item.

    Regard
    I know, I know, my English is bad, sorry .....

  5. #5

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,175

    Re: Again problem (a little) with ComboBox

    Quote Originally Posted by Tamgovb
    thanks for quick reply.

    Hmm, good question. I want to simplify the record of code as well as works of project




    The new of item.

    Regard
    When you say "The new of item" do you men that when a new item gets added to the combo that you want to add it a second time? Or do you mean that you want to store the value in a textfile? Or??

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Re: Again problem (a little) with ComboBox

    RhinoBull, sorry, alone you see how I write in English badly.
    Please, don't get upset. You to try me to understand.

    I want to be able the new things I could write directly in Combo and saved into text file. Instead writes to some textboxes, and to rewrite then to Combo and then to file

    Regard
    I know, I know, my English is bad, sorry .....

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Re: Again problem (a little) with ComboBox

    It seemed for me that it will be better so ( more quickly in sense of loss of time) but I see that I'm in the error.
    I understand now, that there is no meaning how I to writes into text file (in sense of transfer of information) because and so later it reading anyway I have this in Combo.

    Sorry again, for my stupid point of sight

    Thanks for you both

    P.S. Martin, or you know that we are almost peers?
    I know, I know, my English is bad, sorry .....

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    Re: Again problem (a little) with ComboBox

    Noooo - noone will ever get upset over misunderstandings ...

    Anyway, if you don't want to assign text to Textbox and then to Combobox then smply add that new value to Combo directly:

    Combo1.AddItem "new text to be added"

    But part I don't know is how you add new text to your textbox in the first place?

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2005
    Location
    in Poland
    Posts
    390

    Re: Again problem (a little) with ComboBox

    hmm, sorry, this I don't understand your question now
    I know, I know, my English is bad, sorry .....

  11. #11
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,335

    Re: Again problem (a little) with ComboBox

    You are adding text from a textbox to your Combo.

    Rhino is asking how does the text get into the textbox. Do you type it in?

    Does it come from a database? A text file?

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