Guten Tag,
ich wollte mir über vba eine Schraubenvoruaswahl treffen. Dafür muss man aus einer Tabelle zum einen die Festigkeitsklasse der Schraube bestimmen und die maximal auftretende Kraft. Aus der Tabelle kann dann der durchmesser der Schraube bestimmt werden.
In meinem Beispiel, haben wir eine Schraube mit der Festigkeitsklasse 4.6 und eine Statisch Axial wirkende Kraft von 1.6, 2.5 und 4 KN. Ich habe die Tabelle in VBA eingepflegt und die Kraft wird über ein Textfeld eingespeist. Die Festigkeitsklasse wird über eine ComboBox eingetragen. über eine If schleife habe ich die auswahl aus der liste getroffen. An dieser Stelle trit mein Fehler auf. Wenn ich in der ComboBox 4.6 auswähle und für die Kraft 1.6 auswähle, gibt mir das Programm den Nenndurchmesser von 6mm aus. Soweit so richtig. Wenn ich jedoch die Kraft auf 2.5 erhöhe wird der Nenndurchmesser nicht auf 8 mm erhöht sondern es bleib bei den 6mm.
Im Anhang ist mein Programmcode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | Private Sub CheckBox1_Click()
End Sub
Private Sub CommandButton1_Click()
Dim ComboBox1() As Double
Dim TextBox1 As Double
Dim TextBox2 As Double
Dim TextBox3 As Double
Dim Vorauswahl(6, 12) As Double
Dim statischAxial(1, 12) As Double
Dim dynamischAxial(1, 12) As Double
Dim quer(1, 12) As Double
statischAxial(1, 1) = 1.6
statischAxial(1, 2) = 2.5
statischAxial(1, 3) = 4
statischAxial(1, 4) = 6.3
statischAxial(1, 5) = 10
statischAxial(1, 6) = 16
statischAxial(1, 7) = 25
statischAxial(1, 8) = 40
statischAxial(1, 9) = 63
statischAxial(1, 10) = 100
statischAxial(1, 11) = 160
statischAxial(1, 12) = 250
dynamischAxial(1, 1) = 1
dynamischAxial(1, 2) = 1.6
dynamischAxial(1, 3) = 2.5
dynamischAxial(1, 4) = 4
dynamischAxial(1, 5) = 6.3
dynamischAxial(1, 6) = 10
dynamischAxial(1, 7) = 16
dynamischAxial(1, 8) = 25
dynamischAxial(1, 9) = 40
dynamischAxial(1, 10) = 63
dynamischAxial(1, 11) = 100
dynamischAxial(1, 12) = 160
quer(1, 1) = 0.32
quer(1, 2) = 0.5
quer(1, 3) = 0.8
quer(1, 4) = 1.25
quer(1, 5) = 2
quer(1, 6) = 3.15
quer(1, 7) = 5
quer(1, 8) = 8
quer(1, 9) = 12.5
quer(1, 10) = 20
quer(1, 11) = 31.5
quer(1, 12) = 50
Vorauswahl(1, 1) = 6
Vorauswahl(1, 2) = 8
Vorauswahl(1, 3) = 10
Vorauswahl(1, 4) = 12
Vorauswahl(1, 5) = 16
Vorauswahl(1, 6) = 20
Vorauswahl(1, 7) = 24
Vorauswahl(1, 8) = 27
Vorauswahl(1, 9) = 33
Vorauswahl(2, 1) = 5
Vorauswahl(2, 2) = 6
Vorauswahl(2, 3) = 8
Vorauswahl(2, 4) = 10
Vorauswahl(2, 5) = 12
Vorauswahl(2, 6) = 16
Vorauswahl(2, 7) = 20
Vorauswahl(2, 8) = 24
Vorauswahl(2, 9) = 30
Vorauswahl(3, 1) = 4
Vorauswahl(3, 2) = 5
Vorauswahl(3, 3) = 6
Vorauswahl(3, 4) = 8
Vorauswahl(3, 5) = 10
Vorauswahl(3, 6) = 12
Vorauswahl(3, 7) = 14
Vorauswahl(3, 8) = 18
Vorauswahl(3, 9) = 22
Vorauswahl(3, 10) = 27
Vorauswahl(4, 1) = 4
Vorauswahl(4, 2) = 5
Vorauswahl(4, 3) = 6
Vorauswahl(4, 4) = 8
Vorauswahl(4, 5) = 8
Vorauswahl(4, 6) = 10
Vorauswahl(4, 7) = 14
Vorauswahl(4, 8) = 16
Vorauswahl(4, 9) = 20
Vorauswahl(4, 10) = 24
Vorauswahl(4, 11) = 30
Vorauswahl(5, 2) = 4
Vorauswahl(5, 3) = 5
Vorauswahl(5, 4) = 6
Vorauswahl(5, 5) = 8
Vorauswahl(5, 6) = 10
Vorauswahl(5, 7) = 12
Vorauswahl(5, 8) = 14
Vorauswahl(5, 9) = 16
Vorauswahl(5, 10) = 20
Vorauswahl(5, 11) = 27
Vorauswahl(5, 12) = 30
Vorauswahl(6, 2) = 4
Vorauswahl(6, 3) = 5
Vorauswahl(6, 4) = 5
Vorauswahl(6, 5) = 8
Vorauswahl(6, 6) = 8
Vorauswahl(6, 7) = 10
Vorauswahl(6, 8) = 12
Vorauswahl(6, 9) = 16
Vorauswahl(6, 10) = 20
Vorauswahl(6, 11) = 24
Vorauswahl(6, 12) = 30
If TextBox1 >= 1.6 Or TextBox1 < 2.5 And Me .ComboBox1 = "4.6" Then
TextBox4 = Vorauswahl(1, 1)
ElseIf TextBox1 >= 2.5 Or TextBox1 < 4 And Me .ComboBox1 = "4.6" Then
TextBox4 = Vorauswahl(1, 2)
ElseIf TextBox1 >= 4 Or TextBox1 < 6 And Me .ComboBox1 = "4.6" Then
TextBox4 = Vorauswahl(1, 3)
End If
End Sub
Private Sub UserForm_Initialize()
With Me .ComboBox1
.AddItem "4.6"
.AddItem "4.8,5.6"
.AddItem "5.8,6.8"
.AddItem "8.8"
.AddItem "10.9"
.AddItem "12.9"
End With
End Sub
|
|