INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

2 ComBo and Text

2 ComBo and Text

(OP)
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

RE: 2 ComBo and Text

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?

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 

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.

RE: 2 ComBo and Text

I rather think the OP means 1-2-3-4-5 and 1-2-3-4-5 in the two combos.

RE: 2 ComBo and Text

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? sad

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.

RE: 2 ComBo and Text

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.

RE: 2 ComBo and Text

So here's just one possible solution:

CODE

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 

RE: 2 ComBo and Text

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

RE: 2 ComBo and Text

So glad you took sight to cite the sites.

Skip,

glassesJust traded in my OLD subtlety...
for a NUance!tongue

RE: 2 ComBo and Text

smile

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close