[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 !
http://i46.photobucket.com/albums/f1...TM/Example.jpg
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,
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 :confused:
VB Code:
Private Sub Combo1_Click()
Dim tmp() As String
tmp = Split(Combo1.Text, "X")
Text1.Text = tmp(0)
Text2.Text = tmp(1)
End Sub
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:
sValue = text1.text & " x " & text2.text
On Error Resume Next
Combo1.Text = sValue
If Err.Number <> 0 Then
If MsgBox("Dimensions not valid, add them?", vbYesNo) = vbYes Then
Combo1.AddItem sValue
Combo1.Text = sValue
End If
End If
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"
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:
sValue = text1.text & " x " & text2.text
On Error Resume Next
Combo1.Text = sValue
If Err.Number <> 0 Then
If MsgBox("Dimensions not valid, add them?", vbYesNo) = vbYes Then
Combo1.AddItem sValue
Combo1.Text = sValue
End If
End If
I cant do that because I can modify the Standard Dimension...
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
So that when you check the rule:
VB Code:
iWidth = Text1.text
For iAdd = iInputWidth to cWidths.Item(cWidths.Count)
On Error Resume Next
Err.Clear
sCheck = cWidths.Item(iWidth)
If Err.Number <>0 then Exit For
iWidth = iWidth + 1
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?
Re: Point to an higher dimension in Combobox...
Quote:
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.
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...
Re: Point to an higher dimension in Combobox...
Will the pattern always be
4x12
4x24
4x36
8x12
8x24
8x36 ?
If so,
VB Code:
Dim customSelection As String
Dim customBuff() As String
customSelection = "15 x 5"
customBuff = Split(Replace(customSelection, " ", ""), "x")
Dim i As Integer
Dim j As Integer
While (Not ((Val(customBuff(0)) + i) Mod 4 = 0))
i = i + 1
Wend
While (Not ((Val(customBuff(1)) + j) Mod 12 = 0))
j = j + 1
Wend
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
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:
Dim customSelection As String
Dim customBuff() As String
customSelection = "15 x 5"
customBuff = Split(Replace(customSelection, " ", ""), "x")
Dim i As Integer
Dim j As Integer
While (Not ((Val(customBuff(0)) + i) Mod 4 = 0))
i = i + 1
Wend
While (Not ((Val(customBuff(1)) + j) Mod 12 = 0))
j = j + 1
Wend
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...
Re: Point to an higher dimension in Combobox...
try something like this
VB Code:
For i = 0 To List1.ListCount - 1
asize = Split(Replace(List1.List(i), " ", ""), "x")
If asize(0) > Val(text1.Text) Then 'width bigger than custom width
If asize(1) > Val(text2.Text) Then Exit For 'height bigger than custom height
End If
Next
List1.ListIndex = i ' if it don't find a standard size bigger both ways selects the last (biggest) in list
Re: Point to an higher dimension in Combobox...
Quote:
Originally Posted by westconn1
try something like this
VB Code:
For i = 0 To List1.ListCount - 1
asize = Split(Replace(List1.List(i), " ", ""), "x")
If asize(0) > Val(text1.Text) Then 'width bigger than custom width
If asize(1) > Val(text2.Text) Then Exit For 'height bigger than custom height
End If
Next
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 !