Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

2 ComBo and Text

Status
Not open for further replies.

MADABLACK

MIS
Dec 25, 2015
1
DZ
Hello everybody
Merry Christmas
I am very pleased to join you in this best forum
Please if you can help me to solve this problem
In Form1 i have Combo1 and Combo2 and Text1
I want when :
I choose in combo1 the number1 and I choose in Combo2 the number1 will appear in Text1 the number "9450"
I choose in combo1 the number1 and I choose in Combo2 the number2 will appear in Text1 the number "9900"
I choose in combo1 the number1 and I choose in Combo2 the number3 will appear in Text1 the number "10350"

I choose in combo1 the number2 and I choose in Combo2 the number1 will appear in Text1 the number "83508"
I choose in combo1 the number2 and I choose in Combo2 the number2 will appear in Text1 the number "10845"
I choose in combo1 the number2 and I choose in Combo2 the number3 will appear in Text1 the number "11340"

I choose in combo1 the number3 and I choose in Combo2 the number1 will appear in Text1 the number "458796"
I choose in combo1 the number3 and I choose in Combo2 the number2 will appear in Text1 the number "254879"
I choose in combo1 the number3 and I choose in Combo2 the number3 will appear in Text1 the number "12457"

and so on with other numbers

In Combo1 i have number (1-2-2-4-5)
In Combo2 i have number (1-2-2-4-5)

I tried to do in this file attached but unfortunately it does not work
Thank you in advance for help me to solve my problem
Cordially
MADA BLACK

 
 http://files.engineering.com/getfile.aspx?folder=c4b426e8-513f-4005-9947-56482628f6f6&file=project.zip
Could you explain the logic (math?) how the choices from Combo1 and Combo2 create the numbers in Text1?
Especially how come the second and third group of selections (which are the same) give different results?

[pre]
Combo1 Combo2 Text1
1 1 9450
1 2 9900
1 2 10350

2 1 83508
2 2 10845
2 2 11340

2 1 458796
2 2 254879
2 2 12457[/pre]

Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
I rather think the OP means 1-2-3-4-5 and 1-2-3-4-5 in the two combos.

 
I believe you are right, that may just be a typo.
But still – what would be the logic / math to get those numbers… ?
Unless ‘hard-coding’ the outcome is an option? :-(


Have fun.

---- Andy

A bus station is where a bus stops. A train station is where a train stops. On my desk, I have a work station.
 
Yes, the 'and so on with the other numbers' is disconcerting. And the linked code proves less than enlightening; perhaps there is a bit missing.
 
So here's just one possible solution:

Code:
[blue]Option Explicit
Private lookup As Collection

Private Sub Combo1_Click()
        Text1 = lookupdata
End Sub

Private Sub Combo2_Click()
        Text1 = lookupdata
End Sub

Private Sub Form_Load()
    Dim a() As Variant
    Dim b() As Variant
    Dim lp As Long
    
    a = Array(11, 12, 13, 21, 22, 23, 31, 32, 33)
    b = Array(9450, 9900, 10350, 83508, 10845, 11340, 458796, 254879, 1245)
    
    Set lookup = New Collection
    For lp = LBound(a) To UBound(a)
        lookup.Add b(lp), CStr(a(lp))
    Next
    
    For lp = 1 To 3
        Combo1.AddItem Str(lp)
        Combo2.AddItem Str(lp)
    Next
    Combo1.ListIndex = 0
    Combo2.ListIndex = 0
End Sub

Private Function lookupdata() As Long
    On Error Resume Next
    lookupdata = lookup.Item(Trim(Combo1.Text) & Trim(Combo2.Text))
End Function[/blue]
 
Ah. A quick check shows that MADABLACK cross-posted this to multiple sites1, got an answer elsewhere, and unfortunately has not had the courtesy to return here to tell us he had a solution, and so wasting our time. <sigh>

1e.g vbforums and help4coding
 
So glad you took sight to cite the sites.

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top