
Robin Grahm
Umeå obin_gam ObinTheGam
Bloggj Snabblänkk Bevaka denna blogg
Mitt program i vb6
Så här ser koden för närvarande ut.
Säg vad jag ska ändra för att få den som jag vill.
Private Sub checkVara1_Click()
If checkVara1.Value = Checked Then
txtAntal1.Visible = True
Else
txtAntal1.Visible = False
txtAntal1.Text = 0
End If
End Sub
Private Sub checkVara2_Click()
If checkVara2.Value = Checked Then
txtAntal2.Visible = True
Else
txtAntal2.Visible = False
txtAntal2.Text = 0
End If
End Sub
Private Sub checkVara3_Click()
If checkVara3.Value = Checked Then
txtAntal3.Visible = True
Else
txtAntal3.Visible = False
txtAntal3.Text = 0
End If
End Sub
Private Sub checkVara4_Click()
If checkVara4.Value = Checked Then
txtAntal4.Visible = True
Else
txtAntal4.Visible = False
txtAntal4.Text = 0
End If
End Sub
Private Sub checkVara5_Click()
If checkVara5.Value = Checked Then
txtAntal5.Visible = True
Else
txtAntal5.Visible = False
txtAntal5.Text = 0
End If
End Sub
Private Sub checkVara6_Click()
If checkVara6.Value = Checked Then
txtAntal6.Visible = True
Else
txtAntal6.Visible = False
txtAntal6.Text = 0
End If
End Sub
’Denna knapp nollställer allt så kunden/användaren kan börja om med sin beställning/betalning.
Private Sub cmdBörjaOm_Click()
totaltPris.Caption = 0
totaltBetalt.Caption = 0
picVäxel.Visible = False
picVäxel.Cls
cmdBetala.Caption = "Betala"
växel.Caption = 0
betalGodtagen.Visible = False
betalOgiltig.Visible = False
End Sub
’Denna knapp räknar ut vad den totala summan av antalet varor som kunden har skrivit in.
’Den ser också till så att kunden inte köper för mycket varor, samt att kunden inte köper för en för stor summa pengar.
Private Sub cmdRäkna_Click()
Dim pris(1 To 6) As Integer
Dim antal(1 To 6) As Integer
Dim summa As Integer
Dim slut As Integer
pris(1) = 1
pris(2) = 10
pris(3) = 100
pris(4) = 250
pris(5) = 500
pris(6) = 600
antal(1) = Int(txtAntal1.Text)
antal(2) = Int(txtAntal2.Text)
antal(3) = Int(txtAntal3.Text)
antal(4) = Int(txtAntal4.Text)
antal(5) = Int(txtAntal5.Text)
antal(6) = Int(txtAntal6.Text)
For i = 1 To 6
summa = summa + antal(i) * pris(i)
Next i
totaltPris.Caption = summa
If summa >= 1001 Then
totaltPris.Caption = "Köp måste vara under 1000:-"
End If
If txtAntal1.Text > 20 Then
txtAntal1.Text = "SLUT"
End If
If txtAntal2.Text > 20 Then
txtAntal2.Text = "SLUT"
End If
If txtAntal3.Text > 15 Then
txtAntal3.Text = "SLUT"
End If
If txtAntal4.Text > 15 Then
txtAntal4.Text = "SLUT"
End If
If txtAntal5.Text > 10 Then
txtAntal5.Text = "SLUT"
End If
If txtAntal6.Text > 10 Then
txtAntal6.Text = "SLUT"
End If
End Sub
‘Dessa koder nedantill ser till att valuta-knapparna sköter sig som dom ska.
Private Sub cmdBetal1_Click()
totaltBetalt.Caption = totaltBetalt + 1
End Sub
Private Sub cmdBetal5_Click()
totaltBetalt.Caption = totaltBetalt + 5
End Sub
Private Sub cmdBetal10_Click()
totaltBetalt.Caption = totaltBetalt + 10
End Sub
Private Sub cmdBetal20_Click()
totaltBetalt.Caption = totaltBetalt + 20
End Sub
Private Sub cmdBetal50_Click()
totaltBetalt.Caption = totaltBetalt + 50
End Sub
Private Sub cmdBetal100_Click()
totaltBetalt.Caption = totaltBetalt + 100
End Sub
Private Sub cmdBetala100_Click()
totaltBetalt.Caption = totaltBetalt + 100
End Sub
Private Sub cmdBetal500_Click()
totaltBetalt.Caption = totaltBetalt + 500
End Sub
’Denna knapp räknar ihop den summa man har valt att betala och räknar ut hur (om) mycket växel man skall få över.
’När den har texten ”Ta ut växel” räknar den upp och delar ut den summa som man ska få och delar ut den i så höga valörer som möjligt.
Private Sub cmdBetala_Click()
Dim växelUt As Integer
Dim växelValör(0 To 6) As Integer
Dim antal As Integer
växelValör(0) = 500
växelValör(1) = 100
växelValör(2) = 50
växelValör(3) = 20
växelValör(4) = 10
växelValör(5) = 5
växelValör(6) = 1
växelUt = växel.Caption
If Int(totaltBetalt.Caption) >= Int(totaltPris.Caption) Then
betalGodtagen.Visible = True
betalOgiltig.Visible = False
växel.Caption = totaltBetalt.Caption - totaltPris.Caption
picVäxel.Visible = True
cmdBetala.Caption = "Ta ut växel"
ElseIf Int(totaltBetalt.Caption) < Int(totaltPris.Caption) Then
betalOgiltig.Visible = True
betalGodtagen.Visible = False
picVäxel.Visible = False
End If
picVäxel.Cls
For i = 0 To 6
antal = Int(växelUt / växelValör(i))
If antal <> 0 Then
picVäxel.Print antal & " st " & växelValör(i) & ":- "
End If
växelUt = växelUt - växelValör(i) * antal
Next i
End Sub
Säg vad jag ska ändra för att få den som jag vill.
Private Sub checkVara1_Click()
If checkVara1.Value = Checked Then
txtAntal1.Visible = True
Else
txtAntal1.Visible = False
txtAntal1.Text = 0
End If
End Sub
Private Sub checkVara2_Click()
If checkVara2.Value = Checked Then
txtAntal2.Visible = True
Else
txtAntal2.Visible = False
txtAntal2.Text = 0
End If
End Sub
Private Sub checkVara3_Click()
If checkVara3.Value = Checked Then
txtAntal3.Visible = True
Else
txtAntal3.Visible = False
txtAntal3.Text = 0
End If
End Sub
Private Sub checkVara4_Click()
If checkVara4.Value = Checked Then
txtAntal4.Visible = True
Else
txtAntal4.Visible = False
txtAntal4.Text = 0
End If
End Sub
Private Sub checkVara5_Click()
If checkVara5.Value = Checked Then
txtAntal5.Visible = True
Else
txtAntal5.Visible = False
txtAntal5.Text = 0
End If
End Sub
Private Sub checkVara6_Click()
If checkVara6.Value = Checked Then
txtAntal6.Visible = True
Else
txtAntal6.Visible = False
txtAntal6.Text = 0
End If
End Sub
’Denna knapp nollställer allt så kunden/användaren kan börja om med sin beställning/betalning.
Private Sub cmdBörjaOm_Click()
totaltPris.Caption = 0
totaltBetalt.Caption = 0
picVäxel.Visible = False
picVäxel.Cls
cmdBetala.Caption = "Betala"
växel.Caption = 0
betalGodtagen.Visible = False
betalOgiltig.Visible = False
End Sub
’Denna knapp räknar ut vad den totala summan av antalet varor som kunden har skrivit in.
’Den ser också till så att kunden inte köper för mycket varor, samt att kunden inte köper för en för stor summa pengar.
Private Sub cmdRäkna_Click()
Dim pris(1 To 6) As Integer
Dim antal(1 To 6) As Integer
Dim summa As Integer
Dim slut As Integer
pris(1) = 1
pris(2) = 10
pris(3) = 100
pris(4) = 250
pris(5) = 500
pris(6) = 600
antal(1) = Int(txtAntal1.Text)
antal(2) = Int(txtAntal2.Text)
antal(3) = Int(txtAntal3.Text)
antal(4) = Int(txtAntal4.Text)
antal(5) = Int(txtAntal5.Text)
antal(6) = Int(txtAntal6.Text)
For i = 1 To 6
summa = summa + antal(i) * pris(i)
Next i
totaltPris.Caption = summa
If summa >= 1001 Then
totaltPris.Caption = "Köp måste vara under 1000:-"
End If
If txtAntal1.Text > 20 Then
txtAntal1.Text = "SLUT"
End If
If txtAntal2.Text > 20 Then
txtAntal2.Text = "SLUT"
End If
If txtAntal3.Text > 15 Then
txtAntal3.Text = "SLUT"
End If
If txtAntal4.Text > 15 Then
txtAntal4.Text = "SLUT"
End If
If txtAntal5.Text > 10 Then
txtAntal5.Text = "SLUT"
End If
If txtAntal6.Text > 10 Then
txtAntal6.Text = "SLUT"
End If
End Sub
‘Dessa koder nedantill ser till att valuta-knapparna sköter sig som dom ska.
Private Sub cmdBetal1_Click()
totaltBetalt.Caption = totaltBetalt + 1
End Sub
Private Sub cmdBetal5_Click()
totaltBetalt.Caption = totaltBetalt + 5
End Sub
Private Sub cmdBetal10_Click()
totaltBetalt.Caption = totaltBetalt + 10
End Sub
Private Sub cmdBetal20_Click()
totaltBetalt.Caption = totaltBetalt + 20
End Sub
Private Sub cmdBetal50_Click()
totaltBetalt.Caption = totaltBetalt + 50
End Sub
Private Sub cmdBetal100_Click()
totaltBetalt.Caption = totaltBetalt + 100
End Sub
Private Sub cmdBetala100_Click()
totaltBetalt.Caption = totaltBetalt + 100
End Sub
Private Sub cmdBetal500_Click()
totaltBetalt.Caption = totaltBetalt + 500
End Sub
’Denna knapp räknar ihop den summa man har valt att betala och räknar ut hur (om) mycket växel man skall få över.
’När den har texten ”Ta ut växel” räknar den upp och delar ut den summa som man ska få och delar ut den i så höga valörer som möjligt.
Private Sub cmdBetala_Click()
Dim växelUt As Integer
Dim växelValör(0 To 6) As Integer
Dim antal As Integer
växelValör(0) = 500
växelValör(1) = 100
växelValör(2) = 50
växelValör(3) = 20
växelValör(4) = 10
växelValör(5) = 5
växelValör(6) = 1
växelUt = växel.Caption
If Int(totaltBetalt.Caption) >= Int(totaltPris.Caption) Then
betalGodtagen.Visible = True
betalOgiltig.Visible = False
växel.Caption = totaltBetalt.Caption - totaltPris.Caption
picVäxel.Visible = True
cmdBetala.Caption = "Ta ut växel"
ElseIf Int(totaltBetalt.Caption) < Int(totaltPris.Caption) Then
betalOgiltig.Visible = True
betalGodtagen.Visible = False
picVäxel.Visible = False
End If
picVäxel.Cls
For i = 0 To 6
antal = Int(växelUt / växelValör(i))
If antal <> 0 Then
picVäxel.Print antal & " st " & växelValör(i) & ":- "
End If
växelUt = växelUt - växelValör(i) * antal
Next i
End Sub
Kommentarer
Kommentera
Du måste vara inloggad för att skriva kommentarer.

Robin Grahm • 21 mar 2007 0q
istället - för lättare läsning