Array Lagerverwaltung II

Blättern im Array, Positionszähler integrieren
Const armax = 99
Private LagList(0 To armax) As TLager
Private pos As Integer
Private Type TLager
  ArtNr As Integer
  ArtGrp As String
  ArtLWert As Double
End Type
Private Sub cmdSuchArtnr_Click()
Dim wert As String, gef As Boolean, i As Integer
lblMeldung.Caption = ""
 If txtArtnr.Text <> "" Then
  wert = Trim$(txtArtnr.Text)
  i = 0
  gef = False
   While i <= armax And Not gef
    If wert = Trim$(LagList(0).ArtNr) Then
     pos = i
     gef = True
    End If
  i = i + 1
  Wend
   If gef Then
    Call anzeigen1
   Else
    lblMeldung.Caption = "Zu Art.-Nr. " & wert & " existiert kein Eintrag"
   End If
 Else
  txtArtnr.SetFocus
 End If
End Sub
Private Sub cmdSuchArtgrp_Click()
Dim wert As String, gef As Boolean, i As Integer
lblMeldung.Caption = ""
 If txtArtgrp.Text <> "" Then
  wert = Trim$(txtArtgrp.Text)
  i = 0
  gef = False
   While i <= armax And Not gef
    If wert = Trim$(LagList(0).ArtGrp) Then
     pos = i
     gef = True
    End If
  i = i + 1
  Wend
   If gef Then
    Call anzeigen2
   Else
    lblMeldung.Caption = "Zu Art-Gruppe.-Nr. " & wert & " existiert kein Lager"
   End If
 Else
  txtArtgrp.SetFocus
 End If
End Sub
Private Sub anzeigen1()
Dim i As Integer
 For i = 0 To armax
  If pos + i <= armax Then
   txtArtgrp.Text = LagList(pos + i).ArtGrp
   lblLgwert.Caption = LagList(pos + i).ArtLWert & " DM"
  End If
 Next i
End Sub
Private Sub anzeigen2()
Dim i As Integer, LagWert As Double
LagWert = 0
 For i = 0 To armax
  If pos + i <= armax Then
   LagWert = LagWert + LagList(i).ArtLWert
  End If
 Next i
lblLgwert.Caption = Format$(LagWert, "###,##0.00") & " DM"
txtArtnr.Text = ""
End Sub
Private Sub cmdDown_Click() Abwärts blättern.
If pos < armax Then
 pos = pos + 1
 Call TabAnzeigen
 cmdUp.Enabled = True
 lblMeldung.Caption = ""
Else
 pos = pos
 cmdDown.Enabled = False
 cmdUp.SetFocus
 lblMeldung.Caption = "Tabellen- Ende !"
End If
End Sub
Private Sub cmdUp_Click() Aufwärts blättern.
If pos > 0 Then
 pos = pos - 1
 Call TabAnzeigen
 cmdDown.Enabled = True
 lblMeldung.Caption = ""
Else
 pos = pos
 cmdUp.Enabled = False
 cmdDown.SetFocus
 lblMeldung.Caption = "Tabellen- Anfang !"
End If
End Sub
Private Sub Form_Load()
 Me.Show
 txtArtnr.SetFocus
 Call TabLaden
 Call TabAnzeigen
End Sub
Private Sub TabLaden()
Dim i As Long
Randomize
 For i = 0 To armax
  LagList(i).ArtGrp = Int((100 - 1) * Rnd + 1)
  LagList(i).ArtLWert = Int((100 - 1) * Rnd + 1)
  LagList(i).ArtNr = Int((100 - 1) * Rnd + 1)
 Next i
End Sub
Private Sub TabAnzeigen()
Dim i As Integer
 For i = 0 To 0
  If pos + i <= armax Then
   txtArtnr.Text = LagList(pos + i).ArtNr
   txtArtgrp.Text = LagList(pos + i).ArtGrp
   lblLgwert.Caption = Format(LagList(pos + i).ArtLWert, "###,##0.00") & " DM"
   lblNr.Caption = " Pos " & pos + i Hier hat sich der Positionszähler versteckt.
  End If
 Next i
End Sub
Private Sub cmdEnde_Click()
 Unload Me
End Sub

 Ranking-Hits zurück Sitemap
Designed by www.wbrnet.info