|
-
Sep 19th, 2006, 06:13 PM
#1
Thread Starter
Hyperactive Member
-
Sep 19th, 2006, 06:17 PM
#2
Lively Member
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,
-
Sep 19th, 2006, 06:24 PM
#3
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:
Private Sub Combo1_Click()
Dim tmp() As String
tmp = Split(Combo1.Text, "X")
Text1.Text = tmp(0)
Text2.Text = tmp(1)
End Sub
-
Sep 19th, 2006, 06:33 PM
#4
Hyperactive Member
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
-
Sep 19th, 2006, 06:39 PM
#5
Thread Starter
Hyperactive Member
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...
-
Sep 19th, 2006, 06:46 PM
#6
Thread Starter
Hyperactive Member
Re: Point to an higher dimension in Combobox...
 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...
DubweiserTM

If your question has been answered, you can mark a thread as resolved...
-
Sep 19th, 2006, 06:52 PM
#7
Hyperactive Member
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?
-
Sep 19th, 2006, 06:54 PM
#8
Hyperactive Member
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.
-
Sep 20th, 2006, 07:05 AM
#9
Thread Starter
Hyperactive Member
Re: Point to an higher dimension in Combobox...
 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...
-
Sep 20th, 2006, 07:35 AM
#10
Hyperactive Member
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
-
Sep 20th, 2006, 07:43 AM
#11
Thread Starter
Hyperactive Member
Re: Point to an higher dimension in Combobox...
 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...
DubweiserTM

If your question has been answered, you can mark a thread as resolved...
-
Sep 20th, 2006, 08:08 AM
#12
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
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
-
Sep 20th, 2006, 08:19 AM
#13
Thread Starter
Hyperactive Member
Re: Point to an higher dimension in Combobox...
 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 !
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|