Results 1 to 13 of 13

Thread: [RESOLVED] Point to an higher dimension in Combobox...

  1. #1

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Resolved [RESOLVED] Point to an higher dimension in Combobox...

    Hi everybody !

    I have 1 Combobox (Combo1) and 2 Textboxes (Text1 and Text2)

    When a user enter a Custom width and height, I want that my app points to the Standard Dimension like the picture above...

    In the example above, custom dimensions are 22 x 16. The next higher dimension for 22 it's 24 and for 16 it's 24

    Is it possible to do this or I dream ??? Thanks in advance !

    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  2. #2
    Lively Member achor's Avatar
    Join Date
    May 2006
    Location
    Porto
    Posts
    123

    Re: Point to an higher dimension in Combobox...

    Hi there,

    What do you want exactly, i didn't understand?

    What do you mean with "I want that my app points to the Standard Dimension like the picture above"

    regards,

  3. #3
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Point to an higher dimension in Combobox...

    Is this what you want?

    If not, I'm the same as achor, a little confused as to what you want to achieve


    VB Code:
    1. Private Sub Combo1_Click()
    2. Dim tmp() As String
    3.  
    4. tmp = Split(Combo1.Text, "X")
    5. Text1.Text = tmp(0)
    6. Text2.Text = tmp(1)
    7.  
    8. End Sub

  4. #4
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    NY
    Posts
    497

    Re: Point to an higher dimension in Combobox...

    Construct a string out of text1 and text2 and set its value to the combo box.

    VB Code:
    1. sValue = text1.text & " x " & text2.text
    2. On Error Resume Next
    3. Combo1.Text = sValue
    4. If Err.Number <> 0 Then
    5.     If MsgBox("Dimensions not valid, add them?", vbYesNo) = vbYes Then
    6.         Combo1.AddItem sValue
    7.         Combo1.Text = sValue
    8.     End If
    9. End If
    end war
    stop greed

  5. #5

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Point to an higher dimension in Combobox...

    In the picture there are custom dimensions 22 x 16

    In the Lostfocus event of Text1 and Text2, I want that my application search in the Combo1 for the next higher dimension. For 22 in the Combobox it's 24 and for 16 it's 24. Then I want that Combo1.Text = "24 x 24"
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  6. #6

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Point to an higher dimension in Combobox...

    Quote Originally Posted by vbmom
    Construct a string out of text1 and text2 and set its value to the combo box.

    VB Code:
    1. sValue = text1.text & " x " & text2.text
    2. On Error Resume Next
    3. Combo1.Text = sValue
    4. If Err.Number <> 0 Then
    5.     If MsgBox("Dimensions not valid, add them?", vbYesNo) = vbYes Then
    6.         Combo1.AddItem sValue
    7.         Combo1.Text = sValue
    8.     End If
    9. End If
    I cant do that because I can modify the Standard Dimension...
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  7. #7
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    NY
    Posts
    497

    Exclamation Re: Point to an higher dimension in Combobox...

    Then construct a for/next, incrementing the user's input until the combo box assignment does not produce an error.

    You may need to create some rules in your code....Maybe create a collection with valid widths. Then a collection with valid lengths (or whatever). When you build the collections, you have to do something like

    VB Code:
    1. cWidths.Add "20","20"

    So that when you check the rule:

    VB Code:
    1. iWidth = Text1.text
    2. For iAdd = iInputWidth to cWidths.Item(cWidths.Count)
    3.    On Error Resume Next
    4.    Err.Clear
    5.    sCheck = cWidths.Item(iWidth)
    6.    If Err.Number <>0 then Exit For
    7.    iWidth = iWidth + 1
    8. Next

    When the user inputs something ridiculous, increment their width/length values, in code like above, until you get to the next valid width/length, comparing to the collection values.

    Make sense?
    end war
    stop greed

  8. #8
    Hyperactive Member
    Join Date
    Jun 2000
    Location
    NY
    Posts
    497

    Re: Point to an higher dimension in Combobox...

    I cant do that because I can modify the Standard Dimension
    You did not explain the application. I'm just giving you an example of what you could do. You'll have to work out your details.
    end war
    stop greed

  9. #9

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Point to an higher dimension in Combobox...

    Quote Originally Posted by vbmom
    You did not explain the application. I'm just giving you an example of what you could do. You'll have to work out your details.
    Im working on an estimating tools for doors and windows. When you choose to work with custom dimensions, I have to find the standard dimension in Combo1 to determine the cost...

    Thanks for your suggestions...
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  10. #10
    Hyperactive Member
    Join Date
    Feb 2006
    Location
    Melbourne, Australia
    Posts
    415

    Re: Point to an higher dimension in Combobox...

    Will the pattern always be
    4x12
    4x24
    4x36
    8x12
    8x24
    8x36 ?

    If so,
    VB Code:
    1. Dim customSelection As String
    2. Dim customBuff() As String
    3.  
    4. customSelection = "15 x 5"
    5. customBuff = Split(Replace(customSelection, " ", ""), "x")
    6. Dim i As Integer
    7. Dim j As Integer
    8. While (Not ((Val(customBuff(0)) + i) Mod 4 = 0))
    9.     i = i + 1
    10. Wend
    11. While (Not ((Val(customBuff(1)) + j) Mod 12 = 0))
    12.     j = j + 1
    13. Wend
    14. MsgBox customBuff(0) + i & " x " & customBuff(1) + j
    This will get the matching standard dimension, using the factors of 4 and 12, in your example

  11. #11

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Point to an higher dimension in Combobox...

    Quote Originally Posted by Rob123
    Will the pattern always be
    4x12
    4x24
    4x36
    8x12
    8x24
    8x36 ?

    If so,
    VB Code:
    1. Dim customSelection As String
    2. Dim customBuff() As String
    3.  
    4. customSelection = "15 x 5"
    5. customBuff = Split(Replace(customSelection, " ", ""), "x")
    6. Dim i As Integer
    7. Dim j As Integer
    8. While (Not ((Val(customBuff(0)) + i) Mod 4 = 0))
    9.     i = i + 1
    10. Wend
    11. While (Not ((Val(customBuff(1)) + j) Mod 12 = 0))
    12.     j = j + 1
    13. Wend
    14. MsgBox customBuff(0) + i & " x " & customBuff(1) + j
    This will get the matching standard dimension, using the factors of 4 and 12, in your example
    There's no factors of 4 and 12. It's only for the example...
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Point to an higher dimension in Combobox...

    try something like this
    VB Code:
    1. For i = 0 To List1.ListCount - 1
    2.     asize = Split(Replace(List1.List(i), " ", ""), "x")
    3.     If asize(0) > Val(text1.Text) Then 'width bigger than custom width
    4.         If asize(1) > Val(text2.Text) Then Exit For 'height bigger than custom height
    5.     End If
    6. Next
    7. List1.ListIndex = i ' if it don't find a standard size bigger both ways selects the last (biggest) in list
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  13. #13

    Thread Starter
    Hyperactive Member DubweiserTM's Avatar
    Join Date
    Dec 2005
    Location
    St-Ferdinand, Québec
    Posts
    427

    Re: Point to an higher dimension in Combobox...

    Quote Originally Posted by westconn1
    try something like this
    VB Code:
    1. For i = 0 To List1.ListCount - 1
    2.     asize = Split(Replace(List1.List(i), " ", ""), "x")
    3.     If asize(0) > Val(text1.Text) Then 'width bigger than custom width
    4.         If asize(1) > Val(text2.Text) Then Exit For 'height bigger than custom height
    5.     End If
    6. Next
    7. List1.ListIndex = i ' if it don't find a standard size bigger both ways selects the last (biggest) in list
    Yesser ! You got it ! Thank you very good !
    DubweiserTM

    If your question has been answered, you can mark a thread as resolved...

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