Ich habe folgende Situation.
10 TextBoxen die erstmal relevant sind bzw. 11
Ich habe einen fixen "Command" dieser wäre in dem Fall "$Perfection".
je nachdem was ich in den TextBoxen ausgenommen die Name TextBox schreibe soll in der Command TextBox ausgegeben werden.
Wenn die Slot TextBox leer ist oder die Zahl 0 hat soll "$Perfection 0 0" in der Command TextBox ausgegeben werden.
Wenn man jedoch zusätzlich noch in die Perfection TextBox eine Zahl zwischen 0 und 100 eingibt soll die Command TextBox "$Perfection 0 0 100" ausgeben.
Das selbe gilt für die anderen 8 TextBoxen welche ein Bild links davon haben, mit dem einzigen Unterschied das von links nach rechts die zweite Zahl im "Command" sich verändert.
"$Perfection 0 1 100"
"$Perfection 0 2 100"
"$Perfection 0 3 100"
"$Perfection 0 4 100"
"$Perfection 0 5 100"
"$Perfection 0 6 100"
"$Perfection 0 7 100"
"$Perfection 0 8 100"
die erste Zahl dieses "Commands wird weiterhin von der Eingabe in der Slot TextBox berücksichtigt.
Die Zahl 100 hab ich in den obigen 9 Beispielen als Eingabe "100" in der jeweiligen TextBox genommen.
Klickt man dann die ComboBox "$edit" an soll das Label und die TextBox "NAME" sichtbar werden.
fast alles bleibt gleich bis auf das sich der vorherige Command zu "$edit NAME $Perfection 0 0 100" verändert.
heißt es ändert sich jediglich der Anfang des Commands und der "NAME" welcher von der NAME TextBox ausgelesen wird.
Der Rest bleibt alles gleich bzw. der Command nach dem NAMEN.
Ich hoffe ich habe das gut erklärt.
Ich hatte einen Code nur dieser sieht mir nach brutalem Müll aus und bzw. aber auch die Funktion ist nicht 100% richtig.
Ich möchte einen sauberen Code bzw. was neues dazu lernen denn das kann es nicht sein das ich das alles nur über If Abfragen lösen kann.
VB.NET-Quellcode
- Public Class SPPerfection
- '######################################################## SPECIALIST CARDS PERFECTION ########################################################
- Private Sub TextBox_SPPSlot_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPSlot.TextChanged
- '######################################################## SP PERFECTION ########################################################
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "0 " + TextBox_SPP.Text
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "1 " + TextBox_SPPAtk.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 0 " + TextBox_SPP.Text
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 1 " + TextBox_SPPAtk.Text
- End If
- '######################################################## SP PERFECTION ATK ########################################################
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "1 " + TextBox_SPPAtk.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 1 " + TextBox_SPPAtk.Text
- End If
- '######################################################## SP PERFECTION DEF ########################################################
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "2 " + TextBox_SPPDef.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 2 " + TextBox_SPPDef.Text
- End If
- '######################################################## SP PERFECTION PROP ########################################################
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "3 " + TextBox_SPPProp.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 3 " + TextBox_SPPProp.Text
- End If
- '######################################################## SP PERFECTION HP/MP ########################################################
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "4 " + TextBox_SPPHPMP.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 4 " + TextBox_SPPHPMP.Text
- End If
- '######################################################## SP PERFECTION FIRE ########################################################
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "5 " + TextBox_SPPFire.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 5 " + TextBox_SPPFire.Text
- End If
- '######################################################## SP PERFECTION WATER ########################################################
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "6 " + TextBox_SPPWater.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 6 " + TextBox_SPPWater.Text
- End If
- '######################################################## SP PERFECTION LIGHT ########################################################
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "7 " + TextBox_SPPLight.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 7 " + TextBox_SPPLight.Text
- End If
- '######################################################## SP PERFECTION SHADOW ########################################################
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "8 " + TextBox_SPPShadow.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 8 " + TextBox_SPPShadow.Text
- End If
- End Sub
- '######################################################## COMMAND FEATURE ########################################################
- '######################################################## ########################################################
- Private Sub TextBox_SPP_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPP.TextChanged
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "0 " + TextBox_SPP.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 0 " + TextBox_SPP.Text
- End If
- End Sub
- '######################################################## SP PERFECTION ATK ########################################################
- Private Sub TextBox_SPPAtk_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPAtk.TextChanged
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "1 " + TextBox_SPPAtk.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 1 " + TextBox_SPPAtk.Text
- End If
- End Sub
- '######################################################## SP PERFECTION DEF ########################################################
- Private Sub TextBox_SPPDef_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPDef.TextChanged
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "2 " + TextBox_SPPDef.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 2 " + TextBox_SPPDef.Text
- End If
- End Sub
- '######################################################## SP PERFECTION PROP ########################################################
- Private Sub TextBox_SPPProp_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPProp.TextChanged
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "3 " + TextBox_SPPProp.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 3 " + TextBox_SPPProp.Text
- End If
- End Sub
- '######################################################## SP PERFECTION HP/MP ########################################################
- Private Sub TextBox_SPPHPMP_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPHPMP.TextChanged
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "4 " + TextBox_SPPHPMP.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 4 " + TextBox_SPPHPMP.Text
- End If
- End Sub
- '######################################################## SP PERFECTION FIRE ########################################################
- Private Sub TextBox_SPPFire_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPFire.TextChanged
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "5 " + TextBox_SPPFire.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 5 " + TextBox_SPPFire.Text
- End If
- End Sub
- '######################################################## SP PERFECTION WATER ########################################################
- Private Sub TextBox_SPPWater_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPWater.TextChanged
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "6 " + TextBox_SPPWater.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 6 " + TextBox_SPPWater.Text
- End If
- End Sub
- '######################################################## SP PERFECTION LIGHT ########################################################
- Private Sub TextBox_SPPLight_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPLight.TextChanged
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "7 " + TextBox_SPPLight.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 7 " + TextBox_SPPLight.Text
- End If
- End Sub
- '######################################################## SP PERFECTION SHADOW ########################################################
- Private Sub TextBox_SPPShadow_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPShadow.TextChanged
- If TextBox_SPPSlot.Text = "" Or "0" Then
- TextBox_SPPCommand.Text = "$Perfection " + "0 " + "8 " + TextBox_SPPShadow.Text
- Else
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 8 " + TextBox_SPPShadow.Text
- End If
- End Sub
- Private Sub TextBox_SPPCommand_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPCommand.TextChanged
- 'When Empty don't show Clipboard Icon
- If TextBox_SPPCommand.Text = "" Then
- GunaImageButton_ClipSPP.Visible = False
- End If
- '<<<------>>>
- 'Show Clipboard Icon & Hide Checkmark Icon
- GunaImageButton_ClipSPP.Visible = True
- GunaImageButton_CheckmarkSPP.Visible = False
- '<<<------>>>
- End Sub
- End Class
Der Code beinhaltet erstmal nur den Command ohne $edit.
Ich weiß der Code ist der letzte Rotz aber für mehr reichen meine Skills erstmal leider nicht aus.
VB.NET-Quellcode
- Public Class SPPerfection
- Private Sub TextBox_SPPSlot_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPSlot.TextChanged
- If TextBox_SPPSlot.Text = "" Then
- TextBox_SPPSlot.Text = "0"
- End If
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " " + TextBox_SPP.Text
- End Sub
- Private Sub TextBox_SPP_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPP.TextChanged
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 0 " + TextBox_SPP.Text
- End Sub
- Private Sub TextBox_SPPAtk_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPAtk.TextChanged
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 1 " + TextBox_SPPAtk.Text
- End Sub
- Private Sub TextBox_SPPDef_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPDef.TextChanged
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 2 " + TextBox_SPPDef.Text
- End Sub
- Private Sub TextBox_SPPProp_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPProp.TextChanged
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 3 " + TextBox_SPPProp.Text
- End Sub
- Private Sub TextBox_SPPHPMP_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPHPMP.TextChanged
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 4 " + TextBox_SPPHPMP.Text
- End Sub
- Private Sub TextBox_SPPFire_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPFire.TextChanged
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 5 " + TextBox_SPPFire.Text
- End Sub
- Private Sub TextBox_SPPWater_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPWater.TextChanged
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 6 " + TextBox_SPPWater.Text
- End Sub
- Private Sub TextBox_SPPLight_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPLight.TextChanged
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 7 " + TextBox_SPPLight.Text
- End Sub
- Private Sub TextBox_SPPShadow_TextChanged(sender As Object, e As EventArgs) Handles TextBox_SPPShadow.TextChanged
- TextBox_SPPCommand.Text = "$Perfection " + TextBox_SPPSlot.Text + " 8 " + TextBox_SPPShadow.Text
- End Sub
- Private Sub GunaCheckBox_SPPE_CheckedChanged(sender As Object, e As EventArgs) Handles GunaCheckBox_SPPE.CheckedChanged
- If GunaCheckBox_SPPE.Checked Then
- Label_SPPName.Visible = True
- TextBox_SPPName.Visible = True
- Else
- Label_SPPName.Visible = False
- TextBox_SPPName.Visible = False
- End If
- TextBox_SPPCommand.Text = "$edit " + TextBox_SPPName.Text + "$Perfection" + " " + TextBox_SPPSlot.Text
- End Sub
- End Class
Ich weiß nicht ob dieser Code besser ist bzw. schöner aber mehr als das habe ich erstmal nicht hinbekommen.
Ich hoffe ihr habt mein Anliegen verstanden und könnt mir helfen das sauber zu lösen.
LG
Dieser Beitrag wurde bereits 3 mal editiert, zuletzt von „MrSKY“ ()