Results 1 to 3 of 3

Thread: [RESOLVED] [2005] Load Value in combo when opening file

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    163

    Resolved [RESOLVED] [2005] Load Value in combo when opening file

    I have a couple of combo boxes and would like to load a value in them when I open a save file. I have already done this and will explain how shortly. Then you will see my problem and why I'd like a different way.

    I have 13 different options for this particular combo box. Each option has a number in front of it which corresponds to the value of that option when it's used in a cmd line program. At this time I use the substring command to get the number off the string in the combo box. Then I use that in a temp file for running a cmd line program and when I create a save file. Then when I read the save file to load values back into the program I use the code to fill in the combo box.

    tboxs(40) is the number value read from the save file
    Code:
                    If tboxs(40) = 1 Then
                        cbtd.Text = "1    0.062 Steel"
                    ElseIf tboxs(40) = 2 Then
                        cbtd.Text = "2    0.072 Steel"
                    ElseIf tboxs(40) = 3 Then
                        cbtd.Text = "3    0.082 Steel"
                    ElseIf tboxs(40) = 4 Then
                        cbtd.Text = "4    0.105 Plain"
                    ElseIf tboxs(40) = 5 Then
                        cbtd.Text = "5    0.052 Steel"
                    ElseIf tboxs(40) = 6 Then
                        cbtd.Text = "6    0.052 Aluminum"
                    ElseIf tboxs(40) = 7 Then
                        cbtd.Text = "7    0.062 Aluminum"
                    ElseIf tboxs(40) = 8 Then
                        cbtd.Text = "8    0.072 Aluminum"
                    ElseIf tboxs(40) = 9 Then
                        cbtd.Text = "9    Double Dimple"
                    ElseIf tboxs(40) = 10 Then
                        cbtd.Text = "10   Single Dimple"
                    ElseIf tboxs(40) = 11 Then
                        cbtd.Text = "11   0.092   ???"
                    ElseIf tboxs(40) = 12 Then
                        cbtd.Text = "12   Fat(Hog)"
                    ElseIf tboxs(40) = 13 Then
                        cbtd.Text = "13   Plain(Laminar)"
                    End If
    I'm having a hard time wording this so please stick with me.

    I have the 13 options listed in the items property of the combo box. Is there a way to call those values in the program and then compare the value of tboxs(40) to the number in the option.

    So I could compare tboxs(40) to the first item listed in the combo box then the next and so on till I get a match then set the combo to that matched item.

    This would make it easy when I have 150 items in a combo box so I don't have to make a huge if elseif statement.

    I know I could just write the current value of the combo box to my save file and load that very easily but that would alter the formatting of my save file since I'd be writing text strings and not just numbers. If there isn't an easy way to do this I guess I'll be stuck with this method.

    I'd really appreciate some help.
    Thanks

  2. #2
    Addicted Member
    Join Date
    Dec 2008
    Posts
    185

    Re: [2005] Load Value in combo when opening file

    Does this work?

    sbtd.selecteditem = sbtd.items(tboxs(40) - 1)

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 2008
    Posts
    163

    Re: [2005] Load Value in combo when opening file

    wow thank you sooooo much

    That was so easy

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