Rem Kirjoittanut Kai Timoskainen Dim IsoNappain$ Dim nimivanha% Dim laskunopud% Dim uusikirj% Sub Form_Load () Top = ylareuna% Left = vasenreuna% tekstia$ = "Laskutusohjelma. Versio " + versi$ + ". Laatinut Kai Timoskainen, Kisa tie 7, 82300 R„„kkyl„. Puh 013-314900. Rekister”idy k„ytt„j„ksi, lisenssimaksu vai n 300 mk. Kirjoita asiakkasi nimi ja osoitetiedot sek„ tarvittaessa muuta laskun " Label1.caption = tekstia$ + "numeroa ja maksuaikaa. " form9.Hide uusikirj% = FALSE Show 'n„yt„ lomake Laskut.Form Label1.caption = Label1.caption + " T„n„„n on: " + Format$(tanaan!, "d/m/yyyy") Vakioviesti.text = Tiedot$ If inivirhe% = TRUE Then MsgBox "Tiedoston LASKUTUS.INI avaus ei onnistunut. Sinun tulee tehd„ alkuaset ukset ja sen j„lkeen lopeta ohjelma ja aloita uudestaan!" Load form3 End If Maksuaika.text = Format$(erapaiv!, "ddddd") If eraantyy$ = "" Then Maksuehdot.text = Erapaiva$ Else Maksuehdot.text = eraantyy$ End If Posti.text = l1posti$ Viitteenne.text = l1viite$ Toimitus.text = l1toimitus$ Laskuno.text = Str$(lno&) For j% = 1 To nimiluku% Nimi.AddItem Asiakkaat$(j%) Next Huomautusaika.text = huomautus$ Exit Sub End Sub Sub Lopeta_Click () lopetus End Sub Sub Tlopeta_Click () lopetus End Sub Sub Asetukset_Click () Load form3 'Show form3 End Sub Sub Jatka_Click () asiakas$ = Nimi.text asosoite$ = Osoite.text asposti$ = Posti.text Tiedot$ = Vakioviesti.text If lomake2piilossa% = TRUE Then form2.Show lomake2piilossa% = FALSE Else Load form2 End If End Sub Sub Nimi_LostFocus () uusikirj% = FALSE If nimivanha% = FALSE Then Exit Sub Osoite.text = Osoitteet$(Nimi.ListIndex + 1) Posti.text = Postit$(Nimi.ListIndex + 1) End Sub Sub Osoite_Change () 'OsMuutettu% = True End Sub Sub Osoite_LostFocus () 'uusikirj% = FALSE End Sub Sub Osoite_GotFocus () Valaise Osoite 'merkataan teksti End Sub Sub Posti_GotFocus () Valaise Posti End Sub Sub Posti_LostFocus () 'uusikirj% = FALSE End Sub Sub Posti_KeyPress (KeyAscii As Integer) C$ = Chr$(KeyAscii) 'muutetaan posti isoille KeyAscii = Asc(UCase$(C$)) 'kirjaimille ' If uusikirj% = FALSE And Not (keyascii = 13 Or keyascii = 9) Then ' uusikirj% = TRUE ' Posti.text = "" ' End If If KeyAscii = 13 Or KeyAscii = 9 Then ' uusikirj% = FALSE Viitteenne.SetFocus End If If KeyAscii = Asc(erotin$) Then KeyAscii = 39 End Sub Sub Nimi_KeyDown (KeyCode As Integer, Shift As Integer) If Shift > 0 And KeyCode = ALAS Then Osoite.SetFocus If Shift > 0 And KeyCode = YLOS Then Laskuno.SetFocus If Shift = 2 And KeyCode = OIKEA Then Viitteenne.SetFocus If KeyCode = OIKEA Or KeyCode = VASEN Then uusikirj% = TRUE End Sub Sub Osoite_KeyDown (KeyCode As Integer, Shift As Integer) If KeyCode = ALAS Then Posti.SetFocus If KeyCode = YLOS Then Nimi.SetFocus If Shift = 2 And KeyCode = OIKEA Then Toimitus.SetFocus 'If keycode = OIKEA Or keycode = VASEN Then uusikirj% = TRUE End Sub Sub Posti_KeyDown (KeyCode As Integer, Shift As Integer) If KeyCode = YLOS Then Osoite.SetFocus If Shift = 2 And KeyCode = OIKEA Then Maksuehdot.SetFocus 'If keycode = OIKEA Or keycode = VASEN Then uusikirj% = TRUE End Sub Sub Laskuno_KeyDown (KeyCode As Integer, Shift As Integer) If KeyCode = ALAS Then Viitteenne.SetFocus If Shift = 2 And KeyCode = VASEN Then Nimi.SetFocus End Sub Sub Viitteenne_KeyDown (KeyCode As Integer, Shift As Integer) If KeyCode = ALAS Then Toimitus.SetFocus If KeyCode = YLOS Then Laskuno.SetFocus If Shift = 2 And KeyCode = VASEN Then Nimi.SetFocus End Sub Sub Maksuehdot_KeyDown (KeyCode As Integer, Shift As Integer) If KeyCode = ALAS Then Huomautusaika.SetFocus If KeyCode = YLOS Then Toimitus.SetFocus If Shift = 2 And KeyCode = VASEN Then Posti.SetFocus If Shift = 2 And KeyCode = OIKEA Then Maksuaika.SetFocus 'If keycode = OIKEA Or keycode = VASEN Then uusikirj% = TRUE End Sub Sub Huomautusaika_KeyDown (KeyCode As Integer, Shift As Integer) If KeyCode = ALAS Then Jatka.SetFocus If KeyCode = YLOS Then Maksuehdot.SetFocus If Shift = 2 And KeyCode = VASEN Then Nimi.SetFocus End Sub Sub Form_Unload (Cancel As Integer) On Local Error GoTo paivavika If MuistaLomake.Value = 1 Then 'talletetaan er„p„iv„ seuraavaa asiakasta varten erapaiv! = DateValue(Maksuaika.text) l1posti$ = Posti.text l1viite$ = Viitteenne.text l1toimitus$ = Toimitus.text eraantyy$ = Maksuehdot.text Tiedot$ = Vakioviesti.text Else l1posti$ = "" l1viite$ = "" l1toimitus$ = "" eraantyy$ = "" End If form9.Show Exit Sub paivavika: erapaiv! = tanaan! + Maika% Resume Next End Sub Sub Apua_Click () Load form7 form7.Suhtfont.visible = FALSE form7.Label1.visible = FALSE form7.Fonttino.visible = FALSE form7.Ok.visible = FALSE form7.Peru.caption = "Ok" form7.caption = "Laskutus - Ohjeita" form7.fontname = "Helv" form7.currenty = 0 form7.Print form7.Print "N„pp„imet t„ll„ lomakkeella:" form7.Print "Sarkain -siirry seuraaavaan kohteeseen" form7.Print "Vaihto-sarkain -palaa takaisin" form7.Print "Alt ja alleviivattu kirjain-siirry suoraan kohteeseen" form7.Print "CNTR ja nuoli -siirry nuolen suuntaan" form7.Print "Vaihto ja nuoli -tekstilaatikon tekstin maalaaminen" form7.Print form7.Print "Maalatun tekstin voi korvata ylikirjoittamalla uutta teksti„." form7.Print "Tulostus tapahtuu aina automaattisesti lopetettaessa ohjelma." form7.Print "Haluttaessa voidaan tulostusjono ajaa kirjoittimelle Klikkaamal-" form7.Print "Tulosta-nappia tai ALT-U tai CNTRL-P. Jos taas asetuksiin on " form7.Print "laitettu: 'Tulostus joka sivun j„lkeen', ei Tulosta-nappi toimi." form7.Print "Ruksi kohdassa: 'Muista lomake' on tarkoitettu tallettamaan esim." form7.Print "erityismaksuaika. Jos Sinulla on pari asiakasta joille annat huonom-" form7.Print "man tai paremman maksuajan kuin muille voit laskuttaa ne per„kk„in." form7.Print "" form7.Show End Sub Sub tietoja_Click () MsgBox "Ohjelman on kirjoittanut Kai Timoskainen 82300 RˇˇKKYLˇ, puh 013-661344, f ax 314911. Lisenssimaksun 300 mk voi maksaa tilille Op 540603-42293." End Sub Sub Tavaa_Click () MsgBox "Olen pahoillani. Koodi on viel„ kesken kirjoituksen!!! K.T." Exit Sub Load form8 End Sub Sub Ttuhoa_Click () Tiedostotuho% = TRUE Load form8 End Sub Sub Nimi_DropDown () nimivanha% = TRUE End Sub Sub Nimi_KeyPress (KeyAscii As Integer) nimivanha% = FALSE If uusikirj% = FALSE And Not (KeyAscii = 13) Then uusikirj% = TRUE Nimi.text = "" End If If KeyAscii = 13 Or KeyAscii = 9 Then uusikirj% = FALSE Osoite.SetFocus End If If Len(Nimi.text) = 0 Then C$ = Chr$(KeyAscii) 'muutetaan posti isoille KeyAscii = Asc(UCase$(C$)) 'kirjaimille End If If KeyAscii = Asc(erotin$) Then KeyAscii = 39 End Sub Sub Laskuno_DropDown () laskunopud% = TRUE label14.visible = TRUE End Sub Sub Laskuno_GotFocus () oletusno$ = Laskuno.text End Sub Sub Laskuno_DblClick () If laskunopud% = TRUE And Not (Val(Laskuno.text) = Val(oletusno$)) Then luelasku End Sub Sub Osoite_KeyPress (KeyAscii As Integer) 'If uusikirj% = FALSE And Not (keyascii = 13 Or keyascii = 9) Then 'uusikirj% = TRUE 'Osoite.text = "" 'End If If KeyAscii = 13 Then Posti.SetFocus If Len(Osoite.text) = 0 Then C$ = Chr$(KeyAscii) 'muutetaan posti isoille KeyAscii = Asc(UCase$(C$)) 'kirjaimille End If If KeyAscii = Asc(erotin$) Then KeyAscii = 39 End Sub Sub Label3_Click () Laskuno.SetFocus End Sub Sub Label8_Click () Viitteenne.SetFocus End Sub Sub Label4_Click () Maksuehdot.SetFocus End Sub Sub Viitteenne_KeyPress (KeyAscii As Integer) If KeyAscii = 13 Then Toimitus.SetFocus End Sub Sub Maksuehdot_KeyPress (KeyAscii As Integer) If KeyAscii = 13 Then Maksuaika.SetFocus 'If uusikirj% = FALSE And Not (keyascii = 13 Or keyascii = 9) Then 'uusikirj% = TRUE 'Maksuehdot.text = "" 'End If End Sub Sub Toimitus_KeyPress (KeyAscii As Integer) If KeyAscii = 13 Then Maksuehdot.SetFocus End Sub Sub Maksuaika_KeyPress (KeyAscii As Integer) 'If uusikirj% = FALSE And Not (keyascii = 13 Or keyascii = 9) Then 'uusikirj% = TRUE 'Maksuaika.text = "" 'End If If KeyAscii = 13 Then Huomautusaika.SetFocus End Sub Sub Huomautusaika_KeyPress (KeyAscii As Integer) If KeyAscii = 13 Then Jatka.SetFocus End Sub Sub Maksuehdot_GotFocus () Valaise Maksuehdot End Sub Sub Maksuehdot_LostFocus () 'uusikirj% = FALSE End Sub Sub Maksuaika_KeyDown (KeyCode As Integer, Shift As Integer) If Shift = 2 And KeyCode = VASEN Then Maksuehdot.SetFocus 'If keycode = OIKEA Or keycode = VASEN Then uusikirj% = TRUE End Sub Sub Maksuaika_GotFocus () Valaise Maksuaika End Sub Sub Maksuaika_LostFocus () 'uusikirj% = FALSE End Sub Sub Toimitus_KeyDown (KeyCode As Integer, Shift As Integer) If KeyCode = YLOS Then Viitteenne.SetFocus If Shift = 2 And KeyCode = VASEN Then Osoite.SetFocus End Sub Sub Laskuno_LostFocus () If Val(Laskuno.text) = 0 Then Laskuno.text = Str$(lno&) End If End Sub Sub Mtulosta_Click () Printer.EndDoc End Sub Sub TulostaPainike_Click () Printer.EndDoc panemuistiin End Sub Sub Toimitus_GotFocus () Valaise Toimitus End Sub Sub Viitteenne_GotFocus () Valaise Viitteenne End Sub Sub Vakioviesti_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Form_Resize () If WindowState = 0 Then ' don't attempt if form is minimized or maximized Move (Screen.Width - Form1.Width) / 2, (Screen.Height - Form1.Height) / 2 End If End Sub Dim Shared alvrek% Dim Shared rivi$(0 To 70) Sub main () End Sub Sub avaaini () On Local Error GoTo virheselv Open "laskutus.ini" For Input As #1 If inivirhe% = True Then Exit Sub Input #1, a$, lno& Input #1, a$, tarkennin% Input #1, a$, Liike$ Input #1, a$, Liikkeenosoite$ Input #1, a$, Liikkeenposti$ Input #1, a$, liikkeenpuhelin$ Input #1, a$, Tiedot$ Input #1, a$, pank$ Input #1, a$, ptili$ Input #1, a$, Maika% If Maika% < 0 Or Maika% > 180 Then inivirhe% = True Exit Sub End If Input #1, a$, Pankkikorko$ Input #1, a$, Huomautus$ Input #1, a$, Erapaiva$ eraantyy$ = Erapaiva$ Input #1, a$, vero!(1), vero!(2), vero!(3), vero!(4) For i% = 1 To 4 If vero!(i%) < 0 Or vero!(i%) > 99 Then inivirhe% = True Exit Sub End If Next Input #1, a$, trteksti$(1), trteksti$(2), trteksti$(3), trteksti$(4) Input #1, a$, verosis% Input #1, a$, valuutta$, valuutt2$, kurssi# Input #1, a$, vuosi% Input #1, a$, reskontr$ Input #1, a$, rekisteri$ Input #1, a$, penni%, pyorvirhe% Input #1, a$, listaerot% erotin$ = Chr$(listaerot%) Input #1, a$, tilisval% Input #1, a$, tulostinp% If tulostinp% < 0 Or tulostinp% > 1 Then inivirhe% = True Exit Sub End If Input #1, a$, suhteutettu%, fonttinumero% Input #1, a$, osvasmarg!, osylamarg! Input #1, a$, paivarivi!, paivasar! Input #1, a$, otsikko$ Input #1, a$, rivivali! Input #1, a$, lasknosar! Input #1, a$, tlrivi!, tlsarake! Input #1, a$, maxrivit% Input #1, a$, viiterivi!, viitesar! Input #1, a$, summarivi!, summasarake! Input #1, a$, pyrivi!, pysarake! Input #1, a$, puhnor!, puhnosar! Input #1, a$, tiedr!, tiedsar! Input #1, a$, kopiot% Input #1, a$, psalkurivi!, psalkusar! Input #1, a$, psmaksrivi! Input #1, a$, pslnorivi!, pslnosar!, pslnoteksti$ Input #1, a$, psasnrivi!, psasnsar!, psasnteksti$ Input #1, a$, psviirivi!, psviisar!, psviiteksti$ Input #1, a$, pserivi!, psersar!, pserteksti$ Input #1, a$, psummarivi!, psummasar!, psummateksti$ Input #1, a$, kuittion% Input #1, a$, kmarg! Input #1, a$, ksaajar! Input #1, a$, klnorivi! Input #1, a$, kmaksr! Input #1, a$, kviiter! Input #1, a$, ksummar! Input #1, a$, tietor!, tietos!, tieto1$, tieto2$ Input #1, a$ If lno& < 1 Or lno& > 32000 Then lno& = 1 If tarkennin% < 0 Or tarkennin% > 1000 Then MsgBox "Laskutus.ini on hieman seonnut, tarkista ja tee varmuuskopiot ennenkuin ja tkat!" End If If tarkennin% = 1000 Then tarkennin% = 0 Close #1 Exit Sub virheselv: Close #1 inivirhe% = True Resume Next End Sub Sub lopetus () form1.Hide form9.windowstate = 0 form9.Show End Sub Sub Grafkirjotin () kirjvirhe% = FALSE On Error GoTo virhe2 'MsgBox "Lsumma@=" + Str$(lsumma@) + " Testsum@=" + Str$(testsum@) 'GoTo loppu Printer.scalemode = 7 'asetetaan mittayksikk” centimetriksi Printer.fontname = Printer.fonts(fonttinumero%) otsikot 'tulostetaan laskun yl„osa Printer.CurrentY = tlrivi! For i% = 0 To riveja% If tuote$(i%) = "" And lukum$(i%) = "" And larvo@(i%) = 0 And rivinarvo@(i%) = 0 T hen GoTo tyhjarivi Printer.CurrentX = tlsarake! Printer.Print Str$(vk%(i%)) + " " + tuote$(i%); If (Not Val(lukum$(i%)) = 1) Or (Not Val(ale$(i%)) = 0) Then Printer.CurrentX = paivasar! Printer.Print lukum$(i%); Printer.CurrentX = paivasar! + 1 Printer.Print kaunista(Format$(larvo@(i%), "### ##0.00")); ale$(i%); End If Printer.CurrentX = lasknosar! Printer.Print kaunista(Format$(rivinarvo@(i%), "#####0.00")) If i% + 1 Mod maxrivit% = 0 Then Printer.CurrentY = pyrivi! tulostarivi "J A T K U U", tlsarake If tulostinp% = 0 Then 'korjaamme kirjoitinajurin virheit„ Printer.NewPage Else Printer.EndDoc End If otsikot tulostarivi "J A T K O A", tlsarake End If tyhjarivi: Next ' rivimuisti! = Printer.CurrentY tulostarivi kaunista(String$(9, "-")), summasarake! If alvrek% = True And verosis% = 1 Then etumerkki% = -1 Printer.CurrentY = rivimuisti! Printer.CurrentX = tlsarake! Printer.Print "Koodi Verollinen "; Printer.Print " Vero Veroton ALV REK" End If If alvrek% = True And verosis% = 0 Then etumerkki% = 1 Printer.CurrentY = rivimuisti! Printer.CurrentX = tlsarake! Printer.Print "Koodi Veroton "; Printer.Print " Vero Verollinen ALV REK" End If rivimuisti! = Printer.CurrentY tulostarivi kaunista(Format$(testsum@, "### ##0.00")), summasarake! If alvrek% = True Then Printer.CurrentY = rivimuisti! For i% = 1 To 5 Printer.CurrentX = tlsarake! If Not (veroper@(i%) = 0) Then Printer.Print Str$(i%) + " " + kaunista(Format$(veroper@(i%), "#####0.00")) + " "; If vero!(i%) > 0 Then Printer.Print Format$(vero!(i%), "#0.0") + " %"; If veromk@(i%) <> 0 Then Printer.Print kaunista(Format$(veromk@(i%), "####0.00 ")); kaunista(Format$(veroper@(i%) + etumerkki% * veromk@(i%), "#####0.00")); Printer.Print " " + trteksti$(i%) End If Next End If Printer.CurrentY = viiterivi! tulostarivi psviiteksti$ + Format$(viiteno&), viitesar! Printer.CurrentY = summarivi! vierassumma@ = lsumma@ * kurssi# 'penninpy"ristys lsumma@ = (Int((lsumma@ * 100 + (penni% + pyorvirhe%) / 2) / penni%) * penni%) / 1 00 m$ = kaunista(Format$(lsumma@, "### ##0.00")) + " " + valuutta$ tulostarivi m$, summasarake! 'kakkosvaluutalla tulostus: If Not kurssi# = 0 Then m$ = kaunista(Format$(vierassumma@, "### ##0.00")) + " " + valuutt2$ tulostarivi m$, summasarake! End If Printer.CurrentY = pyrivi! tulostarivi pank$, pysarake! tulostarivi ptili$, pysarake! 'pankkisiirto Printer.CurrentY = psalkurivi! tulostarivi pank$, psalkusar! tulostarivi ptili$, psalkusar! Printer.Print tulostarivi Liike$, psalkusar! tulostarivi Liikkeenosoite$, psalkusar! tulostarivi Liikkeenposti$, psalkusar! Printer.CurrentY = psmaksrivi! tulostarivi asiakas$, psalkusar! tulostarivi asosoite$, psalkusar! tulostarivi asposti$, psalkusar! Printer.CurrentY = pslnorivi! tulostarivi (pslnoteksti$ + form1.laskuno.Text), pslnosar! tulostarivi (Format$(tanaan!, "ddddd")), pslnosar! 'printer.currentx = pslnosar! 'printer.Print Format$(tanaan!, "ddddd") + " " + pslnoteksti$ + form1.Laskuno.text If asno% > 0 Then Printer.CurrentY = psasnrivi! Printer.CurrentX = psasnsar! Printer.Print psasnteksti$ + Format$(asno%) End If Printer.CurrentY = psviirivi! Printer.CurrentX = psviisar! Printer.Print psviiteksti$ + Format$(viiteno&, "##### #####") Printer.CurrentY = pserivi! Printer.CurrentX = psersar! Printer.Print pserteksti$ + " " + form1.maksuaika.Text Printer.CurrentY = psummarivi! Printer.CurrentX = psummasar! If tilisval% Then Printer.Print psummateksti$ + " " + (Format$(vierassumma@, "### ##0.00")) Else Printer.Print psummateksti$ + " " + (Format$(lsumma@, "### ##0.00")) End If Printer.CurrentY = tietor! Printer.CurrentX = tietos! Printer.Print tieto1$ Printer.CurrentX = tietos! Printer.Print tieto2$ If kuittion% = 0 Then GoTo loppu 'kuittiosan tulostus Printer.CurrentY = ksaajar! tulostarivi Liike$, kmarg! tulostarivi Liikkeenposti$, kmarg! Printer.CurrentY = klnorivi! a$ = pslnoteksti$ + form1.laskuno.Text tulostarivi a$, kmarg! Printer.CurrentY = kmaksr! tulostarivi asiakas$, kmarg! tulostarivi asosoite$, kmarg! tulostarivi asposti$, kmarg! Printer.CurrentY = kviiter! tulostarivi Str$(viiteno&), kmarg! Printer.CurrentY = ksummar! If tilisval% Then tulostarivi kaunista(Format$(vierassumma@, "### ##0.00")), kmarg! Else tulostarivi kaunista(Format$(lsumma@, "### ##0.00")), kmarg! End If loppu: If tulostinp% = 0 Then Printer.NewPage Else 'korjataan kirjoitinajurin Printer.EndDoc 'ohjelmointivirheit„ End If Exit Sub virhe2: MsgBox "Tulostusvirhe aliohjelmassa Grafkirjoitin no: " + Str$(Err), 0, "Toimintav irhe" kirjvirhe% = True End Sub Static Sub tulostarivi (teksti$, x!) kirjvirhe% = FALSE On Error GoTo virhe5 Printer.CurrentX = x! Printer.Print teksti$ Exit Sub virhe5: kirjvirhe% = True MsgBox "Virhe no: " + Str$(Err) + "Aliohjelmassa TULOSTARIVI", 0, "tulostusvirhe" End Sub Sub laskenta () alvrek% = FALSE laskentaalkaa: For j% = 1 To 4 If vero!(j%) > 0 Then alvrek% = True veromk@(j%) = 0 veroper@(j%) = 0 Next lsumma@ = 0 For i% = 0 To riveja% lsumma@ = lsumma@ + rivinarvo@(i%) veroper@(vk%(i%)) = veroper@(vk%(i%)) + rivinarvo@(i%) Next testsum@ = lsumma@'talletetaan varalta summa ennen py"r. For i% = 1 To 4 If Not verosis% = 0 Then veromk@(i%) = veroper@(i%) * (1 - 100 / (100 + vero!(i%))) Else veromk@(i%) = veroper@(i%) * vero!(i%) / 100 lsumma@ = lsumma@ + veromk@(i%) End If Next ' If Abs(lsumma@ * 100) < (penni% + Abs(pyorvirhe%) + llisa% * 100) Then MsgBox "Laskun summa " + Format$(lsumma@, "#0.00") + " on liian pieni. Siirryt„ „n seuraavaan asiakkaaseen." Load form1 'N_in v_ltet__n nollalaskujen postitus End If lvvalmis: End Sub Function kaunista (argumentti As String) As String pituus% = Len(argumentti) If pituus% > 10 Then pituus% = 10 If suhteutettu% >= 1 Then kaunista = Space$(Int((10 - pituus%) * 1.75)) + argumentti Else kaunista = Space$(10 - pituus%) + argumentti End If End Function Sub otsikot () On Error GoTo virhe3 kirjvirhe% = FALSE Printer.CurrentY = osylamarg! tulostarivi "", osvasmarg! tulostarivi Liike$, osvasmarg! tulostarivi Liikkeenosoite$, osvasmarg! tulostarivi Liikkeenposti$, osvasmarg! i% = 0 ykoord! = Printer.CurrentY ykoord! = Printer.CurrentY + rivivali! Printer.CurrentY = ykoord! tulostarivi asiakas$, osvasmarg! tulostarivi asosoite$, osvasmarg! tulostarivi asposti$, osvasmarg! Printer.CurrentY = puhnor! Printer.CurrentX = puhnosar! Printer.Print liikkeenpuhelin$ Printer.CurrentY = tiedr! Printer.CurrentX = tiedsar! Printer.Print Tiedot$ Printer.CurrentY = paivarivi! tulostarivi Format$(tanaan!, "ddddd") + otsikko$, paivasar! ykoord! = Printer.CurrentY ykoord! = Printer.CurrentY + rivivali! Printer.CurrentY = ykoord! v$ = form1.viitteenne.Text tulostarivi v$, paivasar! ykoord! = Printer.CurrentY ykoord! = Printer.CurrentY + rivivali! Printer.CurrentY = ykoord! If asno% > 0 Then tulostarivi Format$(asno%), paivasar! Else Printer.Print End If ykoord! = Printer.CurrentY ykoord! = Printer.CurrentY + rivivali! Printer.CurrentY = ykoord! t$ = form1.toimitus.Text tulostarivi t$, paivasar! ykoord! = Printer.CurrentY ykoord! = Printer.CurrentY + rivivali! Printer.CurrentY = ykoord! m$ = form1.Maksuehdot.Text + " " + form1.maksuaika.Text tulostarivi m$, paivasar! ykoord! = Printer.CurrentY ykoord! = Printer.CurrentY + rivivali! Printer.CurrentY = ykoord! m$ = form1.Huomautusaika.Text huomrivi! = Printer.CurrentY tulostarivi m$, paivasar! Printer.CurrentY = paivarivi! m$ = form1.laskuno.Text tulostarivi m$, lasknosar! Printer.CurrentY = huomrivi! tulostarivi Pankkikorko$, lasknosar! Printer.CurrentX = tlsarake! Printer.Print "Koodi Tuote"; Printer.CurrentX = paivasar! Printer.Print "M„„r„ A-hinta"; Printer.CurrentX = lasknosar! Printer.Print "Summa" Exit Sub virhe3: kirjvirhe% = True MsgBox "Virhe no: " + Str$(Err) + " aliohjelmassa OTSIKOT", 0, "Tulostusvirhe" End Sub Sub talletaini () If valuutta$ = "" Then valuutta$ = "mk" Open "laskutus.ini" For Output As #1 Write #1, "LaskuNo", lno& Write #1, "TarkenninNumero", tarkennin% Write #1, "Laskuttaja", Liike$ Write #1, "Osoite", Liikkeenosoite$ Write #1, "Posti", Liikkeenposti$ Write #1, "Puhelin", liikkeenpuhelin$ Write #1, "Tiedote", Tiedot$ Write #1, "Pankki", pank$ Write #1, "Tili", ptili$ Write #1, "Maksuaika", Maika% Write #1, "Korko", Pankkikorko$ Write #1, "Huomautusaika", Huomautus$ Write #1, "TekstiEr„p„iv„nEdess„", Erapaiva$ Write #1, "Veroprosentit 1-4", vero!(1), vero!(2), vero!(3), vero!(4) Write #1, "Tuoteryhm„nimet", trteksti$(1), trteksti$(2), trteksti$(3), trteksti$(4 ) Write #1, "AlvSis„ltyyHintoihin", verosis% Write #1, "KotiValuutta2ValuuttaJaKurssi", valuutta$, valuutt2$, kurssi# Write #1, "Vuosi", vuosi% Write #1, "LaskutetutLaskutTiedosto", reskontr$ Write #1, "Asiakasrekisteri", rekisteri$ Write #1, "Penninpy”ristys", penni%, pyorvirhe% If erotin$ = "" Then erotin$ = Chr$(9) Write #1, "Listaerotinmerkki", Asc(erotin$) Write #1, "Tilisiirto2Valuutalla", tilisval% Write #1, "LadataankoTulostinpalvelijaJokaSivunJalkeen", tulostinp% Write #1, "SuhteutettuFonttiJaFonttinumero", suhteutettu%, fonttinumero% Write #1, "Osoitekent„nSijainti", osvasmarg!, osylamarg! Write #1, "P„iv„yksenRiviJaSarake", paivarivi!, paivasar! Write #1, "LaskunOtsikko", otsikko$ Write #1, "Riviv„liOtsikkoOsassa", rivivali! Write #1, "LaskunNumeronSarake", lasknosar! Write #1, "TuoteluettelonAlkuriviJaSarake", tlrivi!, tlsarake! Write #1, "LaskulleMahtuuTuoterivej„", maxrivit% Write #1, "ViitenumeronRiviJaSarake", viiterivi!, viitesar! Write #1, "SummanRiviJaSarake", summarivi!, summasarake! Write #1, "PankkiyhteydenAlkuriviJaSarake", pyrivi!, pysarake! Write #1, "PuhelinnumeronRiviJaSarake", puhnor!, puhnosar! Write #1, "TiedotteenRiviJaSarake", tiedr!, tiedsar! Write #1, "LaskunKopioidenLuku", kopiot% Write #1, "TilisiirronSaajaRivijaSarake", psalkurivi!, psalkusar! Write #1, "TilisiirrronMaksajarivi", psmaksrivi! Write #1, "TilisiirronLaskuNoRiviSarakejaTeksti", pslnorivi!, pslnosar!, pslnoteks ti$ Write #1, "TilisiirronASiakasNumeronRiviSarakeTeksti", psasnrivi!, psasnsar!, psas nteksti$ Write #1, "TilisiirronViiteRiviSarakeJaTeksti", psviirivi!, psviisar!, psviiteksti $ Write #1, "TilisiirronEr„p„iv„RiviSarakejaTeksti", pserivi!, psersar!, pserteksti$ Write #1, "TilisiirronSummaRiviSarakejaTeksti", psummarivi!, psummasar!, psummatek sti$ Write #1, "OnkoKuittiTilisiirronVieress„", kuittion% Write #1, "KuitinVasenMarginaali", kmarg! Write #1, "KuitinSaajaRivi", ksaajar! Write #1, "KuitinLaskuNoRivi", klnorivi! Write #1, "KuitinMaksajaRivi", kmaksr! Write #1, "KuitinViiterivi", kviiter! Write #1, "KuitinSummaRivi", ksummar! Write #1, "Lis„tietoja", tietor!, tietos!, tieto1$, tieto2$ Write #1, "T„m„n tiedoston rivien j„rjestyst„ ei saa muuttaa!" Write #1, "Desimaalipilkun tilalla on k„ytett„v„ pistett„(.)." Write #1, "Rivit ovat muotoa: 'Rivin nimi, pilkku(ja) ja rivin arvo(ja).'" Write #1, "Kai Timoskainen." Close #1 End Sub Function vlaske (arg As Long) As Long 'Viitenumeron laskeminen!!! viite: t1% = 0 'viitenumeron laskeminen alkaa t_st_ viite& = arg i% = 0 tarksilm: t1% = t1% + (viite& Mod 10) * 7 viite& = Int(viite& / 10) t1% = t1% + (viite& Mod 10) * 3 viite& = Int(viite& / 10) t1% = t1% + (viite& Mod 10) * 1 viite& = Int(viite& / 10) i% = i% + 1 If (i% <= 3) And (viite& > 0) GoTo tarksilm t1% = Int((t1% + 9) / 10) * 10 - t1% 't1%=laskettu tarkistusluku, joka lis_t__n laskun numeron per__n, 'jotta saadaan viitenumero vlaske = arg * 10& + t1% '& 10:n per_ss_ takaa, ett_ lukualue ei ylity. ' End Function Sub aloitatulostus () kirjvirhe% = FALSE On Error GoTo virhe1 laskenta If Abs(lsumma@ * 100) < (penni% + Abs(pyorvirhe%) + llisa% * 100) Then vast% = MsgBox("Laskun summa liian pieni, tulostetaanko, OK=KYLLˇ, CANCEL=EI", 1, "Nollalasku") End If If vast% = 2 Then Exit Sub muutettu% = True k% = 0 Print #4, Str$(viiteno&); erotin$; Format$(lsumma@, "#0.00"); erotin$; asiakas$; e rotin$; asosoite$; erotin$; asposti$; erotin$; Format$(Int(tanaan!), "ddddd"); ero tin$; (form1.maksuaika.Text); erotin$; Print #4, Format$(veroper@(1), "#0.00"); erotin$; Format$(veroper@(2), "#0.00"); e rotin$; Format$(veroper@(3), "#0.00"); erotin$; Format$(veroper@(4), "#0.00"); ero tin$; Format$(veroper@(5)) panemuistiin Do k% = k% + 1 Grafkirjotin Loop While k% < kopiot% If kirjvirhe% = True Then Exit Sub lno& = lno& + 1 Unload form1 'asiakas on k„sitelty Response% = True 'asetetaan vipu, joka ohittaa form2:n tarkisus- Unload Form2 'rutiinit Load form1 'siirryt„„n seuraavaan asiakkaaseen Exit Sub virhe1: MsgBox "Tulostusvirhe aliohjelmassa ALOITATULOSTUS no: " + Str$(Err), 0, "Tulostus virhe" End Sub Sub panemuistiin () Exit Sub 'ohjelma on viel„ kesken kirjoituksen...... Open "vanhat" + Format$(tarkennin%, "00") + ".las" For Append As #5 Write #5, "*****", Format$(Val(form1.laskuno.Text), "000000") Write #5, Str$(testsum@), asiakas$ Write #5, asosoite$, asposti$, Str$(Int(tanaan!)) Write #5, form1.viitteenne.Text, Str$(asno%), form1.toimitus.Text, form1.Maksuehdo t.Text, form1.maksuaika.Text, form1.Huomautusaika.Text Write #5, riveja% For i% = 0 To riveja% Write #5, vk%(i%), tuote$(i%), lukum$(i%), larvo@(i%) Next Close #5 End Sub Sub vanhalasku () On Error GoTo tvika If tiedvalittu% = FALSE Then MsgBox "tiedvalittu=False" 'Exit Sub Do Line Input #6, vanhar$ If Mid$(vanhar$, 2, 5) = "*****" Then nolista% = nolista% + 1 form1.laskuno.AddItem Str$(Val(Mid$(vanhar$, 10, 6))) End If Loop Until EOF(6) Close #6 Exit Sub tvika: MsgBox "Vanhojen laskujen luku ei onnistunut", 0, "Tiedosto-avaa" tiedvalittu% = FALSE Resume Next End Sub Sub luelasku () On Local Error GoTo virhe6 Open vanhatlask$ For Input As #6 Do Line Input #6, a$ If Val(Mid$(a$, 10, 6)) = Val(form1.laskuno.Text) Then Exit Do End If Loop Input #6, testsum@, asiakas$ form1.nimi.Text = asiakas$ Input #6, asosoite$, asposti$, laskunpvm$ form1.Osoite.Text = asosoite$ form1.Posti.Text = asposti$ Input #6, viiteteksti$, asno%, toim$, mehdot$, aika$, fuom$ form1.viitteenne.Text = viiteteksti$ form1.toimitus.Text = toim$ form1.Maksuehdot.Text = mehdot$ form1.maksuaika.Text = aika$ form1.Huomautusaika.Text = fuom$ Input #6, riveja% For i% = 0 To riveja% Input #6, vk%(i%), tuote$(i%), lukum$(i%), larvo@(i%) Next Close #6 Exit Sub ' virhe6: MsgBox "virhe aliohjelmassa LUELASKU, virhekoodi:" + Str$(Err) virhe% = True Resume Next End Sub Sub Valaise (TextBox As Control) 'SelectText ' Highlight current entry when the ' user selects a text box. TextBox.SelStart = 0 TextBox.SelLength = Len(TextBox.Text) End Sub ' SelectText Function trim$ (arg$) 'lis„t„„n VB1:st„ puuttuva funktio (on mukana uusissa VB:iss„) trim$ = LTrim$(RTrim$(arg$)) End Function 'Tuotteet.frm lomakekohtaiset muistipaikat: Dim asema% Dim maxasema% Dim summa@ Dim uusikirj% Sub Tuotteet_KeyDown (Index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode = OIKEA And Shift = 2 Then Ahinta(Index).SetFocus If KeyCode = YLOS And Index = 0 Then ylospain If KeyCode = YLOS And Index > 0 Then Tuotteet(Index - 1).SetFocus If KeyCode = ALAS And Index < 8 Then Tuotteet(Index + 1).SetFocus If KeyCode = ALAS And Index = 8 Then tyhjaa% = 0 For i% = 6 To 8 If Tuotteet(i%).Text = "" And Maara(i%).Text = "" And Ahinta(i%).Text = "" Then tyhjaa% = tyhjaa% + 1 Next If tyhjaa% < 3 Then ' laskerivi alaspain ' alaspain on aliohjelma End If End If End Sub Sub Maara_KeyDown (Index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode = VASEN And Shift = 2 Then Tuotteet(Index).SetFocus If KeyCode = OIKEA And Shift = 2 Then Ahinta(Index).SetFocus If KeyCode = YLOS And Index = 0 Then ylospain If KeyCode = YLOS And Index > 0 Then Maara(Index - 1).SetFocus If KeyCode = ALAS And Index < 8 Then Maara(Index + 1).SetFocus If KeyCode = ALAS And Index = 8 Then 'laskerivi alaspain End If End Sub Sub Lopeta_Click () Peru_Click End Sub Sub Form_Load () Show 'Ollaan lomakkeessa: tuotteet.frm Form1.Hide Response% = False asema% = 0 maxasema% = 0 If s2muisti% Then If riveja% > 9 Then riveja% = 9 Rivita laskerivi Else riveja% = 0 rivi% = 0 maxasema% = 0 veromuisti% = 1 For i% = 0 To 8 rivinarvo@(i%) = 0 Next End If For i% = riveja% To 100 tuote$(i%) = "" larvo@(i%) = 0 ale$(i%) = "" lukum$(i%) = "" rivinarvo@(i%) = 0 Next End Sub Sub Ahinta_KeyDown (Index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode = VASEN And Shift = 2 Then Tuotteet(Index).SetFocus If KeyCode = YLOS And Index = 0 Then ylospain If KeyCode = YLOS And Index > 0 Then Ahinta(Index - 1).SetFocus If KeyCode = ALAS And Index < 8 Then Ahinta(Index + 1).SetFocus If KeyCode = ALAS And Index = 8 Then 'laskerivi alaspain End If End Sub Sub Ahinta_KeyPress (Index As Integer, KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If If KeyAscii = 13 Then 'telanpalautus siirt„„ uudelle riville If Index = 8 Then laskerivi alaspain Tuotteet(Index).SetFocus Else Tuotteet(Index + 1).SetFocus End If End If End Sub Sub alaspain () If asema% >= 92 Then Exit Sub asema% = asema% + 1 If maxasema% < asema% Then maxasema% = asema% Rivita End Sub Sub ylospain () asema% = asema% - 1 If asema% < 0 Then asema% = 0 Exit Sub End If Rivita End Sub Sub Verovalinta_Click () veromuisti% = Val(Alv(rivi%).Caption) Load Form5 End Sub Sub Ahinta_GotFocus (Index As Integer) rivi% = Index Valaise Ahinta(Index) End Sub Sub Maara_GotFocus (Index As Integer) rivi% = Index Valaise Maara(Index) End Sub Sub Tuotteet_GotFocus (Index As Integer) rivi% = Index Valaise Tuotteet(Index) End Sub Sub Ahinta_LostFocus (Index As Integer) laskerivi End Sub Sub Maara_LostFocus (Index As Integer) If (Len(Maara(Index).Text) = 0) And Len(Tuotteet(Index).Text) > 0 Then Maara(Index ).Text = "1" laskerivi End Sub Sub laskerivi () On Error GoTo laskuvirhe If riveja% < asema% + rivi% Then riveja% = asema% + rivi% summa@ = 0 ale$(asema% + rivi%) = Alennus(rivi%).Text a@ = Val(Ahinta(rivi%).Text) * Val(Maara(rivi%).Text) 'perustetaan apumuuttuja a@ If Right$(Alennus(rivi%).Text, 1) = "%" Then a@ = a@ + a@ * Val(Alennus(rivi%).Text) / 100 Else a@ = a@ + Val(Alennus(rivi%).Text) End If rivinarvo@(asema% + rivi%) = a@ merkkijono$ = Format$(rivinarvo@(asema% + rivi%), "### ##0.00") Label7(rivi%).Caption = (merkkijono$) tuote$(asema% + rivi%) = Tuotteet(rivi%).Text larvo@(asema% + rivi%) = Val(Ahinta(rivi%).Text) lukum$(asema% + rivi%) = Maara(rivi%).Text vk%(asema% + rivi%) = Val(Alv(rivi%).Caption) For i% = 0 To maxasema% + 8 summa@ = rivinarvo@(i%) + summa@ Next Label9.Caption = (Format$(summa@, "### ##0.00")) Exit Sub laskuvirhe: msg$ = "Rivill„ on jokin virhe kohdassa: " + Maara(rivi%).Text + " tai " + Ahi nta(rivi%).Text + " tai " + Alennus(rivi%).Text MsgBox msg$, 64, "M„„r„, Hinta, Alennus?" Ahinta(rivi%).Text = "" Maara(rivi%).Text = "" Alennus(rivi%).Text = "" Exit Sub Return End Sub Sub Maara_KeyPress (Index As Integer, KeyAscii As Integer) If KeyAscii = 44 Then KeyAscii = 46 If KeyAscii = 13 Then Ahinta(Index).SetFocus End Sub Sub Rivita () For i% = 0 To 8 Tuotteet(i%).Text = tuote$(asema% + i%) If larvo@(asema% + i%) <> 0 Then Rem Ahinta(i%).Text = Format$(larvo@(asema% + i%), "### ##0.00") desim@ = larvo@(asema% + i%) - Fix(larvo@(asema% + i%)) Ahinta(i%).Text = Str$(Fix(larvo@(asema% + i%))) + "." + Format$(desim@ * 1 00, "00") Else Ahinta(i%).Text = "" End If Maara(i%).Text = lukum$(asema% + i%) Alennus(i%).Text = ale$(asema% + i%) If vk%(asema% + i%) > 0 Then Alv(i%).Caption = Str$(vk%(asema% + i%)) Else Alv(i%).Caption = Str$(veromuisti%) End If Label7(i%).Caption = (Format$(rivinarvo@(asema% + i%), "### ##0.00")) Label6(i%).Caption = Str$(asema% + i% + 1) Next If larvo@(asema% + 8) = 0 Then Ahinta(8).Text = "" End Sub Sub Tuotteet_LostFocus (Index As Integer) laskerivi End Sub Sub Tulosta_Click () viiteno& = vlaske(Val(Form1.Laskuno.Text)) aloitatulostus End Sub Sub Peru_Click () msg$ = "Tuhotaanko mahdollisesti kirjoittamasi tuotetiedot? Ok=Tuhotaan, Peru/ Cancel = Ei tuhota, palataan vain edelliselle n„yt”lle." Response% = MsgBox(msg$, 1, "Poistanko tuotteet?") Select Case Response% Case 1 Form1.Show Unload Form2 riveja% = 0 'poistutaan pois Case 2 Form2.Hide lomake2piilossa% = True Form1.Show ' Do not allow close. 'Cancel = True End Select End Sub Sub Apua_Click () Load form7 form7.Suhtfont.Visible = False form7.Label1.Visible = False form7.Fonttino.Visible = False form7.Ok.Visible = False form7.Peru.Caption = "Ok" form7.Caption = "Tuotteet-Apua" form7.currenty = 0 form7.FontName = "Courier New" form7.Print "N„pp„imet t„ll„ lomakkeella:" form7.Print "Sarkain -siirry seuraavaan kentt„„n" form7.Print "Vaihto-sarkain -siirry edelliseen kentt„„n" form7.Print "Telanpalautus -siirry seuraavalle riville. My”s sarkain siirtyy seu- " form7.Print "raavalle riville, mutta vain n„in saat lomakkeelle LISˇˇ RIVEJˇ" form7.Print "Uuuden rivin merkiksi kuuluu pieni piippaus" form7.Print "Nuoli yl”s -siirry yl”sp„in" form7.Print "Nuoli alas -siirry alasp„in" form7.Print "CNTRL-oikea -siirry  -hintaan" form7.Print "CNTRL-vasen -siirry rivin alkuun" form7.Print "DEL -poista kohdistimen oikealta puolen" form7.Print "BACKSPACE -poista kohdistimen vasemmalta puolen" form7.Print "INS -vaihda lis„ystilasta p„„llekirjoituksen ja p„invastoi n" form7.Print " " form7.Print "Tuoterivej„ saa olla max. 99 kpl, m„„r„-sarakkeeseen hyv„ksyt„„n" form7.Print "kokonais- ja desimaaliluvut ja m„„r„n per„ss„ saa olla laatu, esim." form7.Print "kg, kpl, plo tai vastaava. M„„r„ voi olla v„lill„ -9999...+9999" form7.Print "Hinta voidaan antaa kokonaisina markkoina tai desimaalilukuna ja" form7.Print "se voi olla v„lill„ -1 milj. ... +1 milj. Rivin arvo tai loppusumma" form7.Print "eiv„t kuitenkaan saa ylitt„„ 1 miljoonaa markkaa." form7.Print "Desimaalierottimena k„ytet„„n ohjelman ajon aikana pistett„ (.), " form7.Print "joka kuitenkin tulostuksessa muutetaan pilkuksi (,), jos olet Ohjausp aneli" form7.Print "(Control-panel)-ohjelmalla asettanut Windowsin toimimaan SUOMESSA." form7.Print "Tuoteryhm„ (tai verokoodin) per„ss„ n„kyy rivinumero." form7.Print "M„„rittele alennus prosenttialeksi kirjoittamalla luvun per„„n %-merk ki" form7.Print "Tai valuuttam„„r„iseksi kirjoittamalla luvun per„„n valuuttasymboli: " + valuutta$ + "." form7.Print "%-lis„ voidaan m„„ritell„, kun luvun edess„ on plus-merkki ja lopussa %-merkki." form7.Print "Ruksi kohdassa muist„ t„m„ sivu auttaa jos laskutat kahdelle asiakkaa lle" form7.Print "per„kk„in samanlaisen laskun." form7.Show End Sub Sub tieoja_Click () MsgBox "Ohjelman on kirjoittanut Kai Timoskainen 82300 RˇˇKKYLˇ, puh 013-661344,fa x 314911. Lisenssimaksun 300 mk voi maksaa tilille Op 540603-42293." End Sub Sub Tuotteet_KeyPress (Index As Integer, KeyAscii As Integer) If KeyAscii = 13 Then Maara(Index).SetFocus If Len(Tuotteet(Index).Text) = 0 Then C$ = Chr$(KeyAscii) 'muutetaan Alkukirj. isoille KeyAscii = Asc(UCase$(C$)) 'kirjaimille End If End Sub Sub Alennus_KeyDown (Index As Integer, KeyCode As Integer, Shift As Integer) If KeyCode = VASEN And Shift = 2 Then Tuotteet(Index).SetFocus If KeyCode = YLOS And Index = 0 Then ylospain If KeyCode = YLOS And Index > 0 Then Alennus(Index - 1).SetFocus If KeyCode = ALAS And Index < 8 Then Alennus(Index + 1).SetFocus If KeyCode = ALAS And Index = 8 Then alaspain End If End Sub Sub Alennus_GotFocus (Index As Integer) rivi% = Index Valaise Alennus(Index) End Sub Sub Alennus_LostFocus (Index As Integer) On Error GoTo alevika Alennus(Index).Text = LTrim$(RTrim$(Alennus(Index).Text)) If Not Val(Alennus(Index).Text) = 0 Then If Not (Left$(Alennus(Index).Text, 1) = "+" Or Val(Alennus(Index).Text) < 0) Then Alennus(Index).Text = "-" + Alennus(Index).Text If Not (Right$(Alennus(Index).Text, 1) = "%" Or Right$(Alennus(Index).Text, Len(v aluutta$)) = valuutta$) Then MsgBox "Alennustapa on m„„ritelt„v„ joko % tai " + valuutta$ + " -m„„r„iseksi! ( Per„„n %-merkki tai valuuttasymboli " + valuutta$ + ").", 0, "Alennustapa?" Alennus(Index).Text = "" End If Else Alennus(Index).Text = "" End If If (Right$(Alennus(Index).Text, 1) = "%" And Abs(Val(Alennus(Index).Text)) > 100) Or (Right$(Alennus(Index).Text, Len(valuutta$)) = valuutta$ And Abs(Val(Alennus(In dex).Text)) > Val(Ahinta(Index).Text) * Val(Maara(Index).Text)) Then MsgBox "Alennus tai lis„maksu on oltava kohtuullinen. Ajattele asiakasta!", 0, " ˇlyt”nt„!" Alennus(Index).Text = "" End If laskerivi Exit Sub alevika: MsgBox "Alennus" + Alennus(Index).Text + " on m„„ritelty jotenkin v„„rin, korjaa o le hyv„", 0, "Virhe alennuksessa" Alennus(Index).Text = "" laskerivi Exit Sub End Sub Sub Alennus_KeyPress (Index As Integer, KeyAscii As Integer) If KeyAscii = 44 Then KeyAscii = 46 End If If KeyAscii = 13 Then If Index = 8 Then laskerivi alaspain Tuotteet(Index).SetFocus Else Tuotteet(Index + 1).SetFocus End If End If End Sub Sub Form_Unload (Cancel As Integer) s2muisti% = MuistaSivu.Value End Sub Sub Form_Resize () If WindowState = 0 Then ' don't attempt if form is minimized or maximized Move (Screen.Width - Form2.Width) / 2, (Screen.Height - Form2.Height) / 2 End If End Sub Sub Talleta_Click () muutettu% = True Liike$ = Laskuttaja.text Liikkeenosoite$ = Osoite.text Liikkeenposti$ = Posti.text Liikkeenpuhelin$ = Puhelin.text Tiedot$ = Tiedote.text Pank$ = Pankki.text Ptili$ = Tili.text Maika% = Val(Maksuaika.text) Pankkikorko$ = Korko.text Huomautus$ = Huomaika.text Erapaiva$ = Erap.text Vero!(1) = Val(Vero1.text) Vero!(2) = Val(Vero2.text) Vero!(3) = Val(Vero3.text) Vero!(4) = Val(Vero4.text) Verosis% = Alvsis.value Tekstik% = 0 'Tekstikirjoitin.value reskontr$ = Resktied.text rekisteri$ = Rektied.text trteksti$(1) = trText1.text trteksti$(2) = trText2.text trteksti$(3) = trText3.text trteksti$(4) = trText4.text trteksti$(5) = "Veroton tai vero eri laskulla" lno& = Val(LaskuNumero.text) valuutta$ = Kotivaluuta.text kurssi# = Val(Vaihtokurssi.text) valuutt2$ = Valuutta2.text 'Hide Unload Form3 End Sub Sub Form_Load () Show 'Asetus.Form If Tekstik% = 1 Then Label15.visible = True Fontit.visible = False End If If Tekstik% = 0 Then Label15.visible = False Fontit.visible = True End If If inivirhe% = True Then Exit Sub Laskuttaja.text = Liike$ Osoite.text = Liikkeenosoite$ Posti.text = Liikkeenposti$ Puhelin.text = Liikkeenpuhelin$ Tiedote.text = Tiedot$ Pankki.text = Pank$ Tili.text = Ptili$ Maksuaika.text = Format$(Maika%) Korko.text = Pankkikorko$ Huomaika.text = Huomautus$ Erap.text = Erapaiva$ Vero1.text = Format$(Vero!(1)) Vero2.text = Format$(Vero!(2)) Vero3.text = Format$(Vero!(3)) Vero4.text = Format$(Vero!(4)) trText1.text = trteksti$(1) trText2.text = trteksti$(2) trText3.text = trteksti$(3) trText4.text = trteksti$(4) Alvsis.value = Verosis% 'Tekstikirjoitin.value = Tekstik% Resktied.text = reskontr$ Rektied.text = rekisteri$ LaskuNumero.text = Str$(lno&) Kotivaluuta.text = valuutta$ Valuutta2.text = valuutt2$ Vaihtokurssi.text = Str$(kurssi#) End Sub Sub Tekstikirjoitin_Click () Fontit.visible = True Label15.visible = False End Sub Sub Maksuaika_Change () If Val(Maksuaika.text) < 0 Or Val(Maksuaika.text) > 90 Then MsgBox "Maksuaika pit„„ olla 1-90 p„iv„„" End If End Sub Sub Korko_Change () If Val(Korko.text) < 0 Or Val(Korko.text) > 50 Then viesti$ = "Korko pit„„ olla 0-50 %!" MsgBox viesti$ End If End Sub Sub Peru_Click () If inivirhe% = True Then Beep MsgBox "ET OLE TALLETTANUT VIELˇ KAIKKIA ASETUKSIA!" End If Unload Form3 End Sub Sub Kohdistukset_Click () Load form4 End Sub Sub Fontit_Click () Load form7 End Sub Sub Apua_Click () Load form7 form7.Suhtfont.visible = False form7.Label1.visible = False form7.Fonttino.visible = False form7.Ok.visible = False form7.Peru.caption = "Ok" form7.caption = "Asetukset-Apua" form7.currenty = 0 form7.Print form7.Print "Asetuksia teht„ess„ on ehdottoman v„ltt„m„t”nt„, ett„" form7.Print "1. Kaikki asetuslomakkeet KATSOTAAN LˇPI. Jos asetukset ovat oikein e i niit„" form7.Print " ole pakko muuttaa, mutta lomakkeet on varmuuden vuoksi katsottava l„pi" form7.Print " Tarkastettavia lomakkeita ovat: Fontit, Lis„asetukset ja" form7.Print " Pankkisiirto. " form7.Print "2. Katsotut lomakkeet kuitataan OK tai TALLETA -napeilla jos ohjelma ajetaan" form7.Print " ensimm„ist„ kertaa. My”hemmin korjattaessa voidaan k„ytt„„ my”s PE RU" form7.Print " nappia." form7.Print "3. Lopuksi lopetetaan ohjelma." form7.Print "4. Kun ohjelma k„ynnistet„„n uudelleen ovat asetukset voimassa." form7.Print " " form7.Print "Arvonlis„veroprosentteja eli tuoteryhmi„ saa olla 4 kpl." form7.Print " " form7.Print "Jos laskutettujen laskujen luettelon sis„lt„v„ tiedosto ja Asiakasrek isterin" form7.Print "sis„lt„v„ tiedosto ovat samoja, ohjelma tekee itse asiakasrekisterin. " form7.Print "Asiakasrekiserin koon ylitt„ess„ 100 nime„, ylim„„r„iset j„tet„„n huo miotta." form7.Print "Jos taas tiedostoilla on eri nimet, on Sinun itse teht„v„ asiakasreki steri." form7.Print "Asiakasrekisterin rakenne: ensimm„inen rivi on otsikkorivi, jolla on sanat:" form7.Print "VIITE,SUMMA,NIMI,OSOITE ja POSTI listaerotinmerkill„ erotettuna." form7.Print "Listaerotinmerkki on usein sarkainmerkki." form7.Print "Sen j„lkeisille riveille tulevat itse tiedot. Kukin asiakas omalle ri villeen." form7.Show End Sub Sub tietoja_Click () MsgBox "Ohjelman on kirjoittanut Kai Timoskainen 82300 RˇˇKKYLˇ, puh 013-661344, f ax 314911. Lisenssimaksun 300 mk voi maksaa tilille Op 540603-42293." End Sub Sub Laskuttaja_GotFocus () Valaise Laskuttaja End Sub Sub Osoite_GotFocus () Valaise Osoite End Sub Sub Posti_GotFocus () Valaise Posti End Sub Sub Puhelin_GotFocus () Valaise Puhelin End Sub Sub Tiedote_GotFocus () Valaise Tiedote End Sub Sub Pankki_GotFocus () Valaise Pankki End Sub Sub Tili_GotFocus () Valaise Tili End Sub Sub Maksuaika_GotFocus () Valaise Maksuaika End Sub Sub Korko_GotFocus () Valaise Korko End Sub Sub Resktied_GotFocus () Valaise Resktied End Sub Sub Rektied_GotFocus () Valaise Rektied End Sub Sub Huomaika_GotFocus () Valaise Huomaika End Sub Sub Erap_GotFocus () Valaise Erap End Sub Sub Vero1_GotFocus () Valaise Vero1 End Sub Sub Vero2_GotFocus () Valaise Vero2 End Sub Sub Vero3_GotFocus () Valaise Vero3 End Sub Sub Vero4_GotFocus () Valaise Vero4 End Sub Sub trText1_GotFocus () Valaise trText1 End Sub Sub trText2_GotFocus () Valaise trText2 End Sub Sub trText3_GotFocus () Valaise trText3 End Sub Sub trText4_GotFocus () Valaise trText4 End Sub Sub LaskuNumero_Change () If Val(LaskuNumero.text) <> Int(Val(LaskuNumero.text)) Then LaskuNumero.text = Str$(Int(Val(LaskuNumero.text))) End If End Sub Sub LaskuNumero_LostFocus () If Val(LaskuNumero.text) < 1 Or Val(LaskuNumero.text) > 32000 Then LaskuNumero.text = Str$(lno&) End If End Sub Sub LaskuNumero_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then KeyAscii = 46 End If End Sub Sub LaskuNumero_GotFocus () Valaise LaskuNumero End Sub Sub Vaihtokurssi_GotFocus () Valaise Vaihtokurssi End Sub Sub Valuutta2_GotFocus () Valaise Valuutta2 End Sub Sub Kotivaluuta_GotFocus () Valaise Kotivaluuta End Sub Sub Vaihtokurssi_LostFocus () If Val(Vaihtokurssi.text) < 0 Or Val(Vaihtokurssi.text) > 500 Then MsgBox "Valuuttakurssin on oltava v„lill„ 0 . . . 500." Vaihtokurssi.text = Str$(kurssi#) End If End Sub Sub Kotivaluuta_LostFocus () If Len(Kotivaluuta.text) < 1 Or Len(Kotivaluuta.text) > 3 Then MsgBox "Valuuttasymbolit ovat 1-3 kirjaimisia esim mk, FIM, EUR." Kotivaluuta.SetFocus End If End Sub Sub Valuutta2_LostFocus () If Len(Valuutta2.text) > 3 Then MsgBox "Valuuttasymbolit ovat 1-3 kirjaimisia esim mk, FIM, EUR." Valuutta2.SetFocus End If End Sub Sub Vaihtokurssi_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then KeyAscii = 46 End If End Sub Sub Vero1_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then KeyAscii = 46 End If End Sub Sub Vero2_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then KeyAscii = 46 End If End Sub Sub Vero3_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then KeyAscii = 46 End If End Sub Sub Vero4_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then KeyAscii = 46 End If End Sub Sub Tiedote_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Laskuttaja_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Osoite_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Posti_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Puhelin_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Pankki_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Tili_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub trText1_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub trText2_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub trText3_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub trText4_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Erap_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Resktied_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Rektied_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Form_Resize () If WindowState = 0 Then ' don't attempt if form is minimized or maximized Move (Screen.Width - Form3.Width) / 2, (Screen.Height - Form3.Height) / 2 End If End Sub Sub Form_Load () Show If tekstik% = 0 Then Label1.visible = False Alustus.visible = False Else tulostinpalvelija.visible = False Alustus.visible = True Label1.visible = True End If If inivirhe% = True Then Exit Sub Alustus.text = kirjalustus$ Vasmarg.text = Str$(osvasmarg!) Yl„marg.text = Str$(osylamarg!) Riviv.text = Str$(rivivali!) Laskunotsikko.text = otsikko$ Paivaysrivi.text = Str$(paivarivi!) Paivasarake.text = Str$(paivasar!) Lnosarake.text = Str$(lasknosar!) Tuotelrivi.text = Str$(tlrivi!) Tuotelsarake.text = Str$(tlsarake!) Viitenorivi.text = Str$(viiterivi!) Viitenosarake.text = Str$(viitesar!) Loppusrivi.text = Str$(summarivi!) Loppusarake.text = Str$(summasarake!) Pyhtrivi.text = Str$(pyrivi!) Pyhtsarake.text = Str$(pysarake!) Riveja.text = Str$(maxrivit%) Kopioluku.text = Str$(kopiot%) Penninpyor.text = Str$(penni%) Pennivirhe.text = Str$(pyorvirhe%) Viitteenmuod.value = viiteasno% tulostinpalvelija.value = tulostinp% Alustus.text = kirjalust$ Puhnorivi.text = Str$(puhnor!) Puhnosarake.text = Str$(puhnosar!) Tiedrivi.text = Str$(tiedr!) Tiedsarake.text = Str$(tiedsar!) Listaer.text = Str$(Asc(erotin$)) End Sub Sub Pankkisiirto_Click () Load form6 End Sub Sub Perumuutos_Click () If inivirhe% = True Then Beep MsgBox "ET OLE VIELˇ TALLETTANUT KAIKKIA LASKULOMAKKEEN ASETUKSIA!!!" End If Unload Form4 End Sub Sub Isoruotsi_LostFocus () End Sub Sub Isoaa_LostFocus () End Sub Sub Isooo_LostFocus () End Sub Sub Pieniaa_LostFocus () End Sub Sub Pienioo_LostFocus () End Sub Sub Pieniruotsi_LostFocus () End Sub Sub Penninpyor_LostFocus () If Val(Penninpyor.text) < 1 Then Penninpyor.text = "10" End Sub Sub Pennivirhe_LostFocus () If Abs(Val(Pennivirhe.text)) > Val(Penninpyor.text) / 2 Then Pennivirhe.text = "0" End Sub Sub Okei_Click () 'muista alustus kirjalustus$ = Alustus.text osvasmarg! = Val(Vasmarg.text) osylamarg! = Val(Yl„marg.text) rivivali! = Val(Riviv.text) otsikko$ = Laskunotsikko.text paivarivi! = Val(Paivaysrivi.text) paivasar! = Val(Paivasarake.text) lasknosar! = Val(Lnosarake.text) tlrivi! = Val(Tuotelrivi.text) tlsarake! = Val(Tuotelsarake.text) viiterivi! = Val(Viitenorivi.text) viitesar! = Val(Viitenosarake.text) summarivi! = Val(Loppusrivi.text) summasarake! = Val(Loppusarake.text) pyrivi! = Val(Pyhtrivi.text) pysarake! = Val(Pyhtsarake.text) maxrivit% = Val(Riveja.text) kopiot% = Val(Kopioluku.text) penni% = Val(Penninpyor.text) pyorvirhe% = Val(Pennivirhe.text) viiteasno% = Viitteenmuod.value tulostinp% = tulostinpalvelija.value kirjalust$ = Alustus.text puhnor! = Val(Puhnorivi.text) puhnosar! = Val(Puhnosarake.text) tiedr! = Val(Tiedrivi.text) tiedsar! = Val(Tiedsarake.text) erotin$ = Chr$(Val(Listaer.text)) Unload Form4 End Sub Sub Riviv_LostFocus () If Val(Riviv.text) > 1 Then MsgBox "Usein riviv„liksi riitt„nee 0.1..0.7" If Val(Riviv.text) < .1 Then MsgBox "Usein riviv„liksi k„ynee 0.1..0.7" End Sub Sub Riveja_LostFocus () Riveja.text = Format$(Int(Val(Riveja.text))) If Val(Riveja.text) < 5 Then MsgBox "Laskulle sopii aika v„h„n rivej„!" If Val(Riveja.text) > 75 Then MsgBox "Laskulle sopii aika paljon rivej„!" End Sub Sub Kopioluku_LostFocus () If Int(Val(Kopioluku.text)) <> Val(Kopioluku.text) Then Kopioluku.text = Int(Val(K opioluku.text)) If Val(Kopioluku.text) < 1 Or Val(Kopioluku.text) > 5 Then Kopioluku.text = "1" End Sub Sub Apua_Click () Load form7 form7.Suhtfont.visible = False form7.Label1.visible = False form7.Fonttino.visible = False form7.Ok.visible = False form7.Peru.caption = "Ok" form7.caption = "Lis„„ asetuksia-Apua" form7.currenty = 0 form7.Print form7.Print "Tekstien alkukohta ilmoitetaan grafiikkakirjoittimessa centimetrein„. " form7.Print "Tekstikirjoittimessa ilmoitetaan ensin rivinumero ja sitten kirjaimen " form7.Print "paikka rivin alusta alkaen." form7.Print "Penninpy”ristys tehd„„n kahden parametrin avulla." form7.Print "Kun toinen luku on negatiivinen ja puolet ensimmisest„ tehd„„n py”ris tys" form7.Print "aina alasp„in." form7.Print "Kohtaan 'Ladataanko tulostinpalvelija...' kokeile ensin ilman rastia" form7.Print "Joko tulostinohjaimessa tai Visual Basic -k„„nt„j„ss„ olevat virheet" form7.Print "vaativat toisinaan ristin, jos tulostus ei muuten toimi." form7.Print "Listaerottimella tarkoitetaan sit„ merkki„, joka erottaa taulukko-" form7.Print "laskentaohjelmaan siirrett„v„t tiedot toisistaan." End Sub Sub Viitteenmuod_LostFocus () If Viitteenmuod.value = 0 Then Exit Sub MsgBox "Koodi on kirjoittamatta... Lasketaan viite laskun numerosta!" Viitteenmuod.value = 0 End Sub Sub tietoja_Click () MsgBox "Ohjelman on kirjoittanut Kai Timoskainen 82300 RˇˇKKYLˇ, puh 013-661344,fa x 314911. Lisenssimaksun 300 mk voi maksaa tilille Op 540603-42293." End Sub Sub Listaer_LostFocus () If Val(Listaer.text) <= 0 Or Val(Listaer.text) > 255 Then Listaer.text = "9" End Sub Sub Laskunotsikko_KeyPress (KeyAscii As Integer) If KeyAscii = 34 Then KeyAscii = 39 End Sub Sub Riviv_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Lnosarake_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Loppusarake_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Loppusrivi_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Puhnorivi_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Puhnosarake_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Pyhtrivi_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Pyhtsarake_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Tiedrivi_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Tiedsarake_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Tuotelrivi_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Tuotelsarake_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Vasmarg_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Viitenorivi_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Viitenosarake_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Yl„marg_KeyPress (KeyAscii As Integer) If KeyAscii = 44 Then 'desimaalipilkku vaihdetaan desimaalipisteeksi KeyAscii = 46 End If End Sub Sub Form_Resize () If WindowState = 0 Then ' don't attempt if form is minimized or maximized Move (Screen.Width - Form4.Width) / 2, (Screen.Height - Form4.Height) / 2 End If End Sub Global tiedostotuho% Global lomake2piilossa% Global tietor!, tietos!, tieto1$, tieto2$ Global lno& Global tarkennin% Global valuutta$ Global valuutt2$ Global kurssi# Global Liike$ Global Liikkeenosoite$ Global Liikkeenposti$ Global Liikkeenpuhelin$ Global asiakas$ Global asosoite$ Global asposti$ Global Tiedot$ Global Pank$ Global Ptili$ Global Maika% Global Pankkikorko$ Global Huomautus$ Global Erapaiva$ Global eraantyy$ Global erapaiv! Global l1posti$ Global l1viite$ Global l1toimitus$ Global vero!(5) Global veromk@(5) Global Verosis% Global Tekstik% Global reskontr$ Global vuosi% Global tanaan! Global rekisteri$ Global penni% Global pyorvirhe% Global erotin$ Global suhteutettu% Global fonttinumero% Global paivarivi! Global paivasar! Global otsikko$ Global lasknosar! Global tlrivi! Global tlsarake! Global maxrivit% Global kopiot% Global viiterivi! Global viiteno& Global summarivi! Global summasarake! Global pyrivi! Global pysarake! Global inivirhe% Global asiakkaat$(0 To 100) Global Osoitteet$(0 To 100) Global postit$(0 To 100) Global nimiluku% Global aakk%(0 To 8) Global Vastaus% Global trteksti$(5) Global veromuisti% Global rivi% Global riveja% Global tulostinp% 'Global grafrivi! Global rivivali! Global osvasmarg! Global osylamarg! Global kirjalust$ Global puhnor! Global puhnosar! Global tiedr! Global tiedsar! Global tiedvalittu% Global psalkurivi! Global psalkusar! Global psmaksrivi! Global pslnorivi! Global Response% Global pslnosar! Global pslnoteksti$ Global psasnrivi! Global psasnsar! Global psasnteksti$ Global psviirivi! Global psviisar! Global psviiteksti$ Global pserivi! Global psersar! Global pserteksti$ Global psummarivi! Global psummasar! Global psummateksti$ Global kuittion% Global kmarg! Global ksaajar! Global klnorivi! Global kmaksr! Global kviiter! Global ksummar! Global s2muisti% Global tuote$(0 To 100) Global larvo@(0 To 100) Global lukum$(0 To 100) Global ale$(0 To 100) Global vk%(0 To 100) Global veroper@(0 To 5) Global rivinarvo@(0 To 100) Global testsum@ Global lsumma@ Global muutettu% Global viitesar! Global vanhatlask$ Global kirjvirhe% Global tilisval% Global Const True = -1 Global Const False = 0 Global Const Musta = &H0& Global Const Valkoinen = &HFFFFFF 'kursorinohjausnapit: Global Const VASEN = &H25 Global Const YLOS = &H26 Global Const OIKEA = &H27 Global Const ALAS = &H28 Global Const SARKAIN = &H9 Global Const ALKU = &H23 Global Const LOPPU = &H24 Global Const versi$ = " 25.3.2001 " Global ylareuna% Global vasenreuna% Sub Command1_Click () Unload Form5 End Sub Sub Form_Load () Show Alvero(veromuisti% - 1).value = True For i% = 0 To 3 Alvero(i%).caption = "Koodi &" + Format$(i% + 1) + Str$(vero!(i% + 1)) + " % " + t rteksti$(i% + 1) Next End Sub Sub Alvero_Click (index As Integer) veromuisti% = index + 1 End Sub Sub Command1_KeyPress (KeyAscii As Integer) If KeyAscii < 49 Or KeyAscii > 52 Then Exit Sub veromuisti% = KeyAscii - 48 Unload Form5 End Sub Sub Form_Unload (Cancel As Integer) 'tyhjaa% = False form2.Alv(rivi%).caption = Format$(veromuisti%) For i% = rivi% + 1 To 8 If Not form2.Maara(i%).text = "" Then GoTo poistutaan If Not Val(form2.Ahinta(i%).text) = 0 Then GoTo poistutaan 'tyhjaa% = True form2.Alv(i%).caption = Format$(veromuisti%) Next poistutaan: 'if tyhjaa%=..................... form2.Tuotteet(rivi%).SetFocus End Sub Sub Form_Resize () If WindowState = 0 Then ' don't attempt if form is minimized or maximized Move (Screen.Width - Form5.Width) / 2, (Screen.Height - Form5.Height) / 2 End If End Sub Sub Check1_Click () If Check1.value = 1 Then Kuittiraami.visible = True If Check1.value = 0 Then Kuittiraami.visible = FALSE End Sub Sub Form_Load () Show If inivirhe% = True Then Exit Sub If kuittion% = 0 Then Kuittiraami.visible = FALSE alkurivi.text = Str$(psalkurivi!) alkusar.text = Str$(psalkusar!) maksajarivi.text = Str$(psmaksrivi!) lnorivi.text = Str$(pslnorivi!) lnosar.text = Str$(pslnosar!) lnoteksti.text = pslnoteksti$ anorivi.text = Str$(psasnrivi!) anosar.text = Str$(psasnsar!) Asnoteksti.text = psasnteksti$ viiter.text = Str$(psviirivi!) viitesar.text = Str$(psviisar!) Viiteteksti.text = psviiteksti$ erapriv.text = Str$(pserivi!) erapsar.text = Str$(psersar!) Erapteksti.text = pserteksti$ loppusriv.text = Str$(psummarivi!) loppusar.text = Str$(psummasar!) Summateksti.text = psummateksti$ Check1.value = kuittion% Kakkosval.value = tilisval% kuittivasen.text = Str$(kmarg!) kuittisaaja.text = Str$(ksaajar!) kuittilaskno.text = Str$(klnorivi!) kuittimaks.text = Str$(kmaksr!) kuittiviite.text = Str$(kviiter!) kuittisumma.text = Str$(ksummar!) Text1yk.text = Str$(tietor!) Text1xk.text = Str$(tietos!) Texti1.text = tieto1$ Texti2.text = tieto2$ End Sub Sub Peru_Click () If inivirhe% = True Then MsgBox "ET OLE TALLETTANUT PANKKISIIRTO LOMAKKEEN ASETUKS IA!" Unload Form6 End Sub Sub Talleta_Click () psalkurivi! = Val(alkurivi.text) psalkusar! = Val(alkusar.text) psmaksrivi! = Val(maksajarivi.text) pslnorivi! = Val(lnorivi.text) pslnosar! = Val(lnosar.text) pslnoteksti$ = lnoteksti.text psasnrivi! = Val(anorivi.text) psasnsar! = Val(anosar.text) psasnteksti$ = Asnoteksti.text psviirivi! = Val(viiter.text) psviisar! = Val(viitesar.text) psviiteksti$ = Viiteteksti.text pserivi! = Val(erapriv.text) psersar! = Val(erapsar.text) pserteksti$ = Erapteksti.text psummarivi! = Val(loppusriv.text) psummasar! = Val(loppusar.text) psummateksti$ = Summateksti.text kuittion% = Check1.value tilisval% = Kakkosval.value kmarg! = Val(kuittivasen.text) ksaajar! = Val(kuittisaaja.text) klnorivi! = Val(kuittilaskno.text) kmaksr! = Val(kuittimaks.text) kviiter! = Val(kuittiviite.text) ksummar! = Val(kuittisumma.text) tietor! = Val(Text1yk.text) tietos! = Val(Text1xk.text) tieto1$ = Texti1.text tieto2$ = Texti2.text Unload Form6 End Sub Sub Psapua_Click () Load form7 form7.Suhtfont.visible = FALSE form7.Label1.visible = FALSE form7.Fonttino.visible = FALSE form7.Ok.visible = FALSE form7.Peru.caption = "Ok" form7.caption = "Pankkisiirto-Apua" form7.currenty = 0 form7.Print form7.Print "Kaiiki lukuarvot t„ll„ lomakkeella voivat olla joko kokonais tai desi maalilukuja." form7.Print "Mitat ovat centimetrein„ alkaen lomakkeen vasemmasta yl„nurkasta." form7.Print " " form7.Print "c Kai Timoskainen, Kisatie 7, 82300 RˇˇKKYLˇ, puh. 013-661344,fax 314 911" form7.Print "Maksa lisenssimaksu 300 mk tilille OP 540603-42293 tai PSP 800025-647 1167." form7.Print "Valitukset ja parannusehdotukset suoraan minulle. Kiitos!" form7.Show End Sub Sub tietoja_Click () MsgBox "Ohjelman on kirjoittanut Kai Timoskainen 82300 RˇˇKKYLˇ, puh 013-661344, f ax 314911. Lisenssimaksun 300 mk voi maksaa tilille Op 540603-42293." End Sub Sub Form_Resize () If WindowState = 0 Then ' don't attempt if form is minimized or maximized Move (Screen.Width - Form6.Width) / 2, (Screen.Height - Form6.Height) / 2 End If End Sub Sub Form_Load () Show Form7.scalemode = 7 If suhteutettu% = 0 Or suhteutettu% = 1 Then Suhtfont.value = suhteutettu% If fonttinumero% > 0 And fonttinumero% < Printer.FontCount Then Fonttino.text = St r$(fonttinumero%) Print "Tulostimen Fontit eli kirjaimet" ' Print to form. For i% = 0 To Printer.FontCount - 1 Form7.CurrentX = Int((i% + 1) / 30) * 7 If (i% + 1) Mod 30 = 0 Then Form7.CurrentY = 0 Print i%; " "; Printer.Fonts(i%)' Print name of font. If i% = 60 Then Exit For Next Form7.CurrentX = Int((i% + 1) / 30) * 7 Print "Fonttien lukum„„r„: "; Printer.FontCount ' Print count. End Sub Sub Ok_Click () muutetu% = True fonttinumero% = Val(Fonttino.text) suhteutettu% = Suhtfont.value Unload Form7 End Sub Sub Peru_Click () Unload Form7 End Sub Sub Fonttino_Change () If Val(Fonttino.text) < 0 Then Fonttino.text = "0" If Val(Fonttino.text) > Printer.FontCount - 1 Then Fonttino.text = "0" End Sub Sub Form_Resize () If WindowState = 0 Then ' don't attempt if form is minimized or maximized Move (Screen.Width - Form7.Width) / 2, (Screen.Height - Form7.Height) / 2 End If End Sub DefInt A-Z Declare Function GetModuleHandle Lib "Kernel" (ByVal lpProgName$) Declare Function GetModuleUsage Lib "Kernel" (ByVal hModule) Rem funktiot kutsuvat kernelist„ tiedon onko ohjelma jo k„ynniss„ Sub Command1_Click () 'ohjelman lopetusn„pp„in Unload Form9 End Sub Sub Command2_Click () 'peru-n„pp„in Form9.Hide Form1.Show End Sub Sub Form_Load () Rem Tarkistan, onko ohjelma jo k„ynniss„. K„ytet„„n avuksi Windowsin Rem systeemifunktioita: hModule = GetModuleHandle("LASKUT.EXE") Count% = GetModuleUsage(hModule) If Count% > 1 Then MsgBox "Ohjelma on jo k„ynniss„! Ohjelmaa ei ole lupa ajaa monena kopiona. " End End If ylareuna% = 120 vasenreuna% = 120 Form9.WindowState = 0 Command1.Caption = "Keskeyt„" Command2.Visible = FALSE Form9.Show On Local Error GoTo reskselv Label1.Caption = "Odota hetki, Lataan ohjelman tiedostoja... Jos t„m„ kest„„ kauan , poista vanhat rivit laskutettujen laskujen luettelosta." Screen.MousePointer = 11 avaaini If vuosi% = 0 Then tanaan! = Now Else tanaan! = DateSerial(vuosi%, Month(Now), Day(Now)) End If erapaiv! = tanaan! + Maika% If Weekday(erapaiv!) = 1 Then 't„n„„n on sunnuntai erapaiv! = erapaiv! + 1 ElseIf Weekday(erapaiv!) = 7 Then 't„n„„n on lauantai erapaiv! = erapaiv! + 2 End If nimienluku 'Asiakasluettelo luetaan Reset 'Levyluvut on luettu ja aloitetaan kirjoitusjakso 'Open "vanhat" + Format$(tarkennin%, "00") + ".las" For Output As #5 Open reskontr$ For Append As #4 If LOF(4) = 0 Then Print #4, "VIITE"; erotin$; "SUMMA"; erotin$; "NIMI"; erotin$; "OSOITE"; erotin$; "POSTI"; erotin$; "PVM"; erotin$; "MAKSUAIKA"; erotin$; "TR1"; erotin$; "TR2"; erotin$; "TR3"; erotin$; "TR4"; erotin$; "TR5" If virhe% > 0 Then Screen.MousePointer = 0 If reskontr$ = "" Then reskontr$ = "'Nimet”n'" MsgBox "Virhekoodi " + Str$(virhe%) + " avattaessa tiedostoa nimelt„: " + resk ontr$ + ". Virhe ei ole vakava, jos ajat ohjelman eka kertaa!" If reskontr$ = "'Nimet”n'" Then reskontr$ = "" Close #4 End If Screen.MousePointer = 0 Label1.Caption = "Lopetetaanko ohjelman ajo?" Command1.Caption = "&Ok" Command2.Visible = TRUE Load Form1 Exit Sub reskselv: virhe% = Err Resume Next End Sub Sub Form_Unload (Cancel As Integer) tarkennin% = tarkennin% + 1 If tarkennin% > 99 Then tarkennin% = 0 If muutettu% = TRUE Then talletaini End End Sub Sub nimienluku () On Local Error GoTo nimivirhe If Len(rekisteri$) < 2 Then Exit Sub 'ei lyhyit„ nimi„ Open rekisteri$ For Input As #2 Select Case virhe% Case 52 To 55, 64 To 71 viesti$ = "Tiedosto " + rekisteri$ + " ei aukea." MsgBox viesti$ Exit Sub Case 0 Screen.MousePointer = 11 Do Line Input #2, a$ 'luetaan rivi If InStr(a$, erotin$) Then 'jos tietuepituus=0, turha yritt„„ a$ = trim$(Right$(a$, Len(a$) - InStr(a$, erotin$))) 'ohitetaan viitenumero a$ = trim$(Right$(a$, Len(a$) - InStr(a$, erotin$))) 'ohitetaan laskun summa Asiakkaat$(0) = trim$(Left$(a$, InStr(a$, erotin$) - 1)) 'luetaan nimi a$ = trim$(Right$(a$, Len(a$) - InStr(a$, erotin$))) Osoitteet$(0) = trim$(Left$(a$, InStr(a$, erotin$) - 1)) 'luetaan osoite a$ = trim$(Right$(a$, Len(a$) - InStr(a$, erotin$))) Postit$(0) = trim$(Left$(a$, InStr(a$, erotin$) - 1)) 'luetaan posti j% = 99 If j% > i% - 1 Then j% = i% - 1 End If Do While j% >= 0 Asiakkaat$(j% + 1) = Asiakkaat$(j%) Osoitteet$(j% + 1) = Osoitteet$(j%) Postit$(j% + 1) = Postit$(j%) j% = j% - 1 Loop End If i% = i% + 1 If i% > 32000 Then MsgBox "Vanhojen laskujen tiedosto on liian suuri, loppuosa j„i lukematta!", 0 , "Poista rivej„!" Exit Do End If tila% = DoEvents() 'annetaan muille ohjelmille keskeytyksi„ Loop Until EOF(2) If EOF(2) Then i% = i% - 1 Close Screen.MousePointer = 0 nimiluku% = i% If nimiluku% > 99 Then nimiluku% = 99 Case Else viesti$ = "Virhe no " + Format$(virhe%) + " aliohjelmassa nimienluku" MsgBox viesti$ Exit Sub End Select nimivirhe: virhe% = Err Resume Next End Sub Sub Form_Resize () If WindowState = 0 Then ' don't attempt if form is minimized or maximized Move (Screen.Width - Form9.Width) / 2, (Screen.Height - Form9.Height) / 2 End If End Sub Sub Command2_Click () Unload Form8 End Sub Sub Drive1_Change () levymuisti$ = dir1.path On Local Error GoTo levyvika dir1.path = Drive1.drive Exit Sub levyvika: dir1.path = levymuisti$ Resume Next End Sub Sub Dir1_Change () file1.path = dir1.path End Sub Sub File1_Click () label1.caption = UCase$(file1.path) + "\" + UCase$(file1.filename) End Sub Sub File1_PathChange () dir1.path = file1.path ' When File1 path changes, set Dir1 path. End Sub Sub Form_Load () If tiedostotuho% = True Then Form8.caption = "Tuhoa tiedosto" label1.caption = "Napsauta tiedostoa" label2.caption = "Tuhoa tiedosto, joka ei sis„ll„ maksamattomia laskuja napsauttam alla tiedostoa ja OK:ta" End If Form8.Show tiedvalittu% = False Form8.file1.pattern = "vanhat*.las" End Sub Sub Command1_Click () On Local Error GoTo virheav If tiedvalittu% = False Then MsgBox "Tiedostoa ei ole valittu" Unload Form8 Exit Sub End If If tiedostotuho% = True Then Kill label1.caption tiedostotuho% = False Else Open label1.caption For Input As #6 vanhatlask$ = label1.caption vanhalasku End If Unload Form8 Exit Sub virheav: MsgBox "Tiedoston avaus ei onnistunut, virhekoodi " + Str$(Err), 0, "Virhe" tiedvalittu% = False Resume Next End Sub Sub Label1_Change () tiedvalittu% = True End Sub Sub Form_Unload (Cancel As Integer) If tiedostotuho% = True Then tiedostotuho% = False End Sub Sub Form_Resize () If WindowState = 0 Then ' don't attempt if form is minimized or maximized Move (Screen.Width - Form8.Width) / 2, (Screen.Height - Form8.Height) / 2 End If End Sub