Label Wert ändern durch Combo Box

Hallo zusammen,

ich habe folgendes Bsp.:

Private Sub Combo2_Click()
Select Case Combo2.ListIndex

Case 0
If Combo1.Text = "A" Then Label1.Caption = "1"
If Combo1.Text = "B" Then Label1.Caption = "10"
Label1.Visible = True

Case 1

If Combo1.Text = "A" Then Label1.Caption = "2"
If Combo1.Text = "B" Then Label1.Caption = "20"
Label1.Visible = True

End Select


End Sub

Private Sub Form_Load()
Combo1.AddItem "A"
Combo1.AddItem "B"

Combo2.AddItem "1"
Combo2.AddItem "2"

End Sub


so wenn ich also A1 auswähle bekomme ich für label1 den wert 1 raus. wenn ich jedoch
nur die Combo1 ändere sprich auf B, sollte sich die Zahl in Label1 direkt automatisch auf den wert 10 ändern ohne das ich jetzt wieder erst Combo2 auswähle.

Hat jemand eine idee?

Danke im voraus...
 
Da musst Du noch auf das Click-Ereignis von Combo1 reagieren. Bisher reagiert das Programm doch nur, wenn Du in Combo2 clickst.
 
Hallo Ronaldh,

vielen Dank für deine Hilfe, das ist genau nach was ich gesucht hatte.
Mein Fehler war, dass ich Combo1 statt select case mit if gestaltet hatte.

so kannst du mir dann auch noch eine Tip geben zum folgendem:
ich habe das programm nun noch ein wenig erweitert, mit label2, label3, label4 und label5.
Die Zahlen von Label1-Label4 varieren jenach was ich aus den Combos auswähle. Label5 dient nun dazu, ein ergebnis von label1-label4 durch addietion zu bekommen.

Wie mache ich es nun, dass sich dieses label5 auch direkt ändert wenn ich Statt A1, B1 auswähle bzw mich umentscheiden sollte dies zu ändern, ohne das ich wieder auf label5 klicken muss.
Praktisch, das label5 sich aktualisiert.

Danke im voraus...
 
Dann solltest Du für die Labels das Change-Ereignis auswerten.

Code:
Private Sub Label1_Change ()
     Label5.Caption = Str(Val(Label1.Caption)) + Str(Val(Label4.Caption))
End Sub

Und das gleiche natürlich auch für Label4.

Grüsse
ronaldh
 
Hallo Ronaldh,

Also das mit dem Label5 hat diesmal nicht geklappt, der Wert aktualisiert sich nicht automatisch... gibt es nicht einfach ein code um dieses label zu refreshen?

zu dem andern problem, was ich hatte mit der Combo box ist das wenn ich es ausführen möchte, folgendes erscheint:

FEHLRT BEIM KOMPLIIEREN:
Prozedur zu groß

Was mache ich denn dagegen. habe in mein Buch geschaut aber leider nichts dadrin gefunden...
 
prozedur zu gross konnte ich loswerden, habe die Combo2 einfach in zwei teile aufgeteilt.

Was mache ich nun falsch, dass sich der wert in Label5 nicht aktualisiert nachdem ich die combo2 ändere?

jemand eine tip?
 
Hallo Dr Mueller,

hier mein Code für das Label52, was ich möchte, dass sich immer erneut aktualisiert sobald ich einen Wert in der Combobox ändere. Vielen Dank für deine Hilfe.

Private Sub Label52_Click()

'Rechen Code fuer Einkaufskosten

summe = Val(Label62) + Val(Label2) + Val(Label3) + Val(Label4) + Val(Label5) + Val(Text4) _
+ Val(Label6) + Val(Label7) + Val(Label8) + Val(Label9) + Val(Label10) + Val(Label11) _
+ Val(Label12) + Val(Label13) + Val(Label14) + Val(Label15) + Val(Label16) + Val(Label17) _
+ Val(Label18) + Val(Label19) + Val(Label20) + Val(Label21) + Val(Label22) + Val(Label67) _
+ Val(Label68) + Val(Label69) + Val(Label70) + Val(Label54) + Val(Label56) + Val(Text5) _
+ Val(Text23) + Val(Text24) + Val(Text25) + Val(Text26) + Val(Text27) + Val(Text28) + Val(Text29) _
+ Val(Text30) + Val(Text31) + Val(Text32) + Val(Text33) + Val(Text34) + Val(Text35) + Val(Text36) _
+ Val(Text37) + Val(Text37) + Val(Text38) + Val(Text39) + Val(Text15) + Val(Text16) + Val(Text17) _
+ Val(Text18)

Text4.Text = CStr(Text4) 'Input Hollow Shaft
Text5.Text = CStr(Text5) 'Machining
Text23.Text = CStr(Text23) ''J'Adaptor + Coupling
Text24.Text = CStr(Text24) 'Filter Breather
Text25.Text = CStr(Text25) 'Double ext. HSS Shaft
Text26.Text = CStr(Text26) 'Double ext. LSS Shaft
Text27.Text = CStr(Text27) 'Extended Inter Shaft
Text28.Text = CStr(Text28) 'Heavy Duty Bearings
Text29.Text = CStr(Text29) 'HSS Labyrinth Seals
Text30.Text = CStr(Text30) 'LSS Labyrinth Seals
Text31.Text = CStr(Text31) 'Backstop
Text32.Text = CStr(Text32) 'Mount / Remove Kit - SD
Text33.Text = CStr(Text33) 'Mount / Remove Kit - Key
Text34.Text = CStr(Text34) 'Temperature Sensors
Text35.Text = CStr(Text35) 'Keyway LSS
Text36.Text = CStr(Text36) 'Dipstick, Drain etc.
Text37.Text = CStr(Text37) 'Oil Pressure Gauge
Text38.Text = CStr(Text38) 'Drop Bearing & Dry Well
Text39.Text = CStr(Text39) 'Oil Pump, Cooler etc.
Text15.Text = CStr(Text15) 'Packaging
Text16.Text = CStr(Text16) 'for the EXTRAS Box
Text17.Text = CStr(Text17) 'for the EXTRAS Box
Text18.Text = CStr(Text18) 'for the EXTRAS Box

Label62.Caption = CStr(Label62) 'Gearbox
Label2.Caption = CStr(Label2) 'Basic Design
Label3.Caption = CStr(Label3) 'Basic Fabrication
Label4.Caption = CStr(Label4) 'Basic Torquw Arm
Label5.Caption = CStr(Label5) 'Fluid Coupling Extra
Label6.Caption = CStr(Label6) 'Fluid Coupling Drip Tray
Label7.Caption = CStr(Label7) 'BTS Bracket
Label8.Caption = CStr(Label8) 'Hinged Guard
Label9.Caption = CStr(Label9) 'Dowels
Label10.Caption = CStr(Label10) 'LSS Guard
Label11.Caption = CStr(Label11) 'No Load Test
Label12.Caption = CStr(Label12) 'Assembling Labour
Label13.Caption = CStr(Label13) 'Fastener Grade 8.8 std
Label14.Caption = CStr(Label14) 'Laser Alignment
Label15.Caption = CStr(Label15) 'Noise Level Test
Label16.Caption = CStr(Label16) 'Vibration Analysis
Label17.Caption = CStr(Label17) 'std Manuals
Label18.Caption = CStr(Label18) 'Lock Straps
Label19.Caption = CStr(Label19) 'Stainless Nameplate
Label20.Caption = CStr(Label20) 'Stainless Jacking Screws
Label21.Caption = CStr(Label21) 'Surface Prep & Paint
Label22.Caption = CStr(Label22) 'Transport Frames
Label54.Caption = CStr(Label54) 'Danger Label Guards
Label56.Caption = CStr(Label56) 'Fluid Coupling Label
Label67.Caption = CStr(Label67) 'Dipstick
Label68.Caption = CStr(Label68) 'Oil Sight Glass
Label69.Caption = CStr(Label69) 'Oil Drain Assy / Valve
Label70.Caption = CStr(Label70) 'Oil Level Switch

Label52.Caption = CStr(summe)
Label52 = Format(Label52, "#####.00")


End Sub
 
Zurück