Hallo,
wollte das ganze nochmal abändern.
Public Class Form1
Dim WithEvents txtInput As New TextBox With {.Parent = Me, .Width = 150}
Dim WithEvents Länge As New TextBox With {.Parent = Me, .Left = 232, .Width _
= 150}
Dim Info As New Label With {.Parent = Me, .Text = "<= 200", .Top = 25}
Dim Info1 As New Label With {.Parent = Me, .Left = 232, .Text = "> 200", _
.Top = 25}
Dim classlabels, classlabels1 As New List(Of Label)
Dim classfreq, classfreq1 As New List(Of Label)
Dim class_ug As Decimal = -1.2D
Dim class_width As Decimal = 0.3D
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) _
Handles MyBase.Load
Me.Size = New Size(500, 350)
Dim tp As Integer = 50
Dim lh As Integer = 24 'Labelhöhe
Dim lw As Integer = 120 'Labelbreite
'Labels erstellen
classlabels.Add(New Label With {.Text = "kleiner gleich -1,2", .Parent _
= Me, .Width = lw, .Top = tp})
classfreq.Add(New Label With {.Parent = Me, .Left = lw + 5, .Width = _
60, .Top = tp, .Text = "0"})
classlabels1.Add(New Label With {.Text = "kleiner gleich -1,2", .Parent _
= Me, .Width = lw, .Left = 232, .Top = tp})
classfreq1.Add(New Label With {.Parent = Me, .Left = 352, .Width = 60, _
.Top = tp, .Text = "0"})
Dim ug As Decimal = class_ug, w As Decimal = class_width
Dim ug1 As Decimal = class_ug, w1 As Decimal = class_width
For i As Integer = 1 To 8
classlabels.Add(New Label With {.Parent = Me, .Width = lw, .Top = _
tp + i * lh, .Text = ug.ToString("0.00") & " bis " & (ug + _
w).ToString("0.00")})
classfreq.Add(New Label With {.Parent = Me, .Left = lw + 5, .Width _
= 60, .Top = tp + i * lh, .Text = "0"})
ug += w
Next i
For i As Integer = 1 To 8
classlabels.Add(New Label With {.Parent = Me, .Width = lw, .Left = _
232, .Top = tp + i * lh, .Text = ug1.ToString("0.00") & " bis " & _
(ug1 + w1).ToString("0.00")})
classfreq.Add(New Label With {.Parent = Me, .Left = lw + 232, _
.Width = 60, .Top = tp + i * lh, .Text = "0"})
ug1 += w1
Next i
classlabels.Add(New Label With {.Text = "größer 1,2", .Parent = Me, _
.Width = lw, .Top = tp + lh * 9})
classfreq.Add(New Label With {.Parent = Me, .Left = lw + 5, .Width = _
60, .Top = tp + 9 * lh, .Text = "0"})
classlabels1.Add(New Label With {.Text = "größer 1,2", .Parent = Me, _
.Width = lw, .Left = 232, .Top = tp + lh * 9})
classfreq1.Add(New Label With {.Parent = Me, .Left = 352, .Width = 60, _
.Top = tp + 9 * lh, .Text = "0"})
End Sub
Private Sub txtInput_KeyDown(sender As Object, e As _
System.Windows.Forms.KeyEventArgs) Handles txtInput.KeyDown
Dim number As Decimal
If e.KeyCode = Keys.Enter Then
If Not Decimal.TryParse(txtInput.Text, number) Then
MsgBox("Keine gültige Zahl") : Exit Sub
End If
number = Math.Round(number, 2)
If number <= -1.2 Then
classfreq(0).Text = (CInt(classfreq(0).Text) + 1).ToString
ElseIf number > 1.2 Then
classfreq(9).Text = (CInt(classfreq(9).Text) + 1).ToString
Else
For i As Integer = 1 To 8
If number <= class_ug + class_width * i Then
classfreq(i).Text = _
(CInt(classfreq(i).Text) + 1).ToString
Exit For
End If
Next i
End If
End If
End Sub
End Class Wenn ich Werte größer 1,2 eintrage, wird alles in der zweiten Spalte eingetragen? Warum ist das so ?
Und wie kann ich eine zweite Abfrage mit Einordnung <=200 Linke Spalte >200 Rechte Spalte verwirklichen ? |