ahoj tak se mi podarilo castecne vyresit tu moji zadanou praci ale zasekl jsem se pri zadavani tech hlavnich ridicich struktur pro mu program.
muj ukol byl ze ze zadaneho 4 mistneho cisla mam vygenerovat jeho psanou podobu. potrebuji vyresit fazi ve ktere musim oddelit cisla 11-19 od ostatnich (jine vypisovani),ale bohuzel nevim jak na to :(
Private Sub cmd1_Click()
Dim castka As String
castka = txt1.Text
If Len(castka) <> 4 Then
MsgBox "ctyrmistna"
End If
tisic = Left(castka, 1)
Print tisic
If tisic = 1 Then
tisic = "jeden tisíc"
End If
If tisic = 2 Then
tisic = "dva tisíce"
End If
If tisic = 3 Then
tisic = "Tři tisíce"
End If
If tisic = 4 Then
tisic = "čtyři tisíce"
End If
If tisic = 5 Then
tisic = "pět tisíc"
End If
If tisic = 6 Then
tisic = "šest tisíc"
End If
If tisic = 7 Then
tisic = "sedm tisíc"
End If
If tisic = 8 Then
tisic = "osm tisíc"
End If
If tisic = 9 Then
tisic = "devět tisíc"
End If
Print tisic
sto = Mid(castka, 2, 1)
Print sto
If sto = 0 Then
sto = ""
End If
If sto = 1 Then
sto = "sto"
End If
If sto = 2 Then
sto = "dvě stě"
End If
If sto = 3 Then
sto = "tři sta"
End If
If sto = 4 Then
sto = "čtyři sta"
End If
If sto = 5 Then
sto = "pět set"
End If
If sto = 6 Then
sto = "šest set"
End If
If sto = 7 Then
sto = "sedm set"
End If
If sto = 8 Then
sto = "osm set"
End If
If sto = 9 Then
sto = "devět set"
End If
Print sto
deset = Mid(castka, 3, 1)
Print deset
If deset = 0 Then
deset = ""
End If
If deset = 2 Then
deset = "dvacet"
End If
If deset = 3 Then
deset = "třicet"
End If
If deset = 4 Then
deset = "čtyřicet"
End If
If deset = 5 Then
deset = "padesát"
End If
If deset = 6 Then
deset = "šedesát"
End If
If deset = 7 Then
deset = "sedmdesát"
End If
If deset = 8 Then
deset = "osmdesát"
End If
If deset = 9 Then
deset = "devadesát"
End If
Print deset
jedna = Right(castka, 1)
Print jedna
If jedna = 0 Then
jedna = ""
End If
If jedna = 1 Then
jedna = "jedna"
End If
If jedna = 2 Then
jedna = "dva"
End If
If jedna = 3 Then
jedna = "tři"
End If
If jedna = 4 Then
jedna = "čtyři"
End If
If jedna = 5 Then
jedna = "pět"
End If
If jedna = 6 Then
jedna = "šest"
End If
If jedna = 7 Then
jedna = "sedm"
End If
If jedna = 8 Then
jedna = "osm"
End If
If jedna = 9 Then
jedna = "devět"
End If
Print jedna
deset1 = Mid(castka, 3, 4)
Print deset1
If deset1 = 10 Then
deset1 = "deset"
End If
If deset1 = 11 Then
deset1 = "jedenáct"
End If
If deset1 = 12 Then
deset1 = "dvanáct"
End If
If deset1 = 13 Then
deset1 = "třináct"
End If
If deset1 = 14 Then
deset1 = "čtrnáct"
End If
If deset1 = 15 Then
deset1 = "patnáct"
End If
If deset1 = 16 Then
deset1 = "šestnáct"
End If
If deset1 = 17 Then
deset1 = "sedmnáct"
End If
If deset1 = 18 Then
deset1 = "osmnáct"
End If
If deset1 = 19 Then
deset1 = "devatenáct"
End If
Print deset1
txt2.Text = tisic & " " & "" & sto & " " & deset1 & deset & " " & jedna
End Sub
Fórum › Visual Basic
Semestralka- vyladeni chyb

to je jednoduchy, tam jak máš tu poslední sekci kde máš ty IFy pro čísla 10-19, tak např. místo
If deset1 = 10 Then
deset1 = "deset"
End If
dej tohle
If deset1 = 10 Then
deset = "deset"
jedna = ""
End If
a jako konečný vypis dej tohle
txt2.Text = tisic & " " & "" & sto & " " & deset & " " & jedna
jen ti to bude na konci vypisovat mezeru na konci, když se bude jednat o ty čísla (10-19), ale to by šlo vyřešit tím, že u všech jednotek dáš před číslo mezeru takhle:
jedna = " čtyři"
a vypis bude takhle: txt2.Text = tisic & " " & "" & sto & " " & deset & jedna
a ještě něco, proč to máš udělaný tak, že když máš jiné číslo než čtyřmístné, tak ti to hodí chybu, měl bys to udělat i pro číslice menší než 4 místné
Tak jiz sem to vyresil, ale trocha jednoduseji - za ty podminky jsem hodil SElect CAse s tim ze kdyz bude Case 10-19, tak deset = deset1 a je vymalovano :) no ja sem mel v zadani napsano ze se mam omezit na ctyrmistna cisla, tak jsem to bral tak ze se jedna pouze o ctyrmistna, snad to neni mysleno ze maji byt maximalne ctyrmistna...
No sp?? si mysl?m, ?e to zad?n? je takov?, ?e maxim?ln? ?ty?cifern?, tedy 1-4 cifern?, takhle by to d?valo v?t?? smysl. Ale nev?m, jak p?esn? to m?? zadan?.

Přidej příspěvek
Toto téma je starší jak čtvrt roku – přidej svůj příspěvek jen tehdy, máš-li k tématu opravdu co říct!
Ano, opravdu chci reagovat → zobrazí formulář pro přidání příspěvku
×Vložení zdrojáku
×Vložení obrázku
×Vložení videa
Aktuálně jsou podporována videa ze serverů YouTube, Vimeo a Dailymotion.
×






























































Uživatelé prohlížející si toto vlákno
Uživatelé on-line: 0 registrovaných, 11 hostů
Podobná vlákna
Semestrálka — založil Tutanchamon
Další semestrálka v C — založil Valik
Semestrálka(okenni aplikace) prosba o radu — založil tomas
Načítání dat ze souboru - nefunguje - Semestrálka — založil firehare
Vyvarování chyb v C — založil anonym
Moderátoři diskuze