ciao a tutti
ma perche non mi funziona??
codice:If Option2 = True Then lire = Round(Val(prezzo.Text) / 1936.27, 2) end if
ciao a tutti
ma perche non mi funziona??
codice:If Option2 = True Then lire = Round(Val(prezzo.Text) / 1936.27, 2) end if
Prova così :
lire = Round((Val(prezzo.Text) / 1936.27), 2)
:bubu:
non va
se io nella casella di testo scrivo "1000 £"
lui mi restituisce 0,52 € mentre se scivo 10.000 £ lui mi restituisce 0,01 € invece di 1,00 €
Scusa ma non ho capito
10000 LIRE = 1.0 EURO
cmq prova questo:
codice:Private Sub Command1_Click() Dim euro As Double euro = Round((txt_lire.Text / 1936.27), 2) Lbl_euro.Caption = euro End Sub
...Terrible warlords, good warlords, and an english song
:quote:
CMQ anche il mio esempio non è esatto!!!
Se per esempio inserisco LIRE 1936.27
mi restituisce 100 EURO colpa del ROUND (....,2)
aggiunge due ZERI (e quindi non va).
...Terrible warlords, good warlords, and an english song
emm..ho sbagliato a scrivere :tongue:Originariamente inviato da Johnny_Depp
Scusa ma non ho capito
10000 LIRE = 1.0 EURO
cmq prova questo:
codice:Private Sub Command1_Click() Dim euro As Double euro = Round((txt_lire.Text / 1936.27), 2) Lbl_euro.Caption = euro End Sub
il tuo codice va quasi bene, fino a che la cifra da convertire non è ad esempio 150.000.000 infatti in questo caso lui scrive: 77468,53
ti spiego maglio
io ho messo in una form un campo di testo e due option ed ho associato questo codice
adesso se scrivo il prezzo in euro cliccando sulla option1 lo trasforma in lire se invece clicco sulla option2 lo trasforma in euro (a parte il problema della formattazione)codice:Private Sub Option1_Click() If Option1 = True And prezzo <> "" Then euro = prezzo * 1936.27 prezzo = euro prezzo = Format(prezzo, "###,##0.00") Else MsgBox "INSERIRE PRIMA LA CIFRA NEL CAMPO PREZZO" Option1 = False End If End Sub Private Sub Option2_Click() If Option2 = True And prezzo <> "" Then Dim euro As Double lire = Round((prezzo.Text / 1936.27), 2) prezzo = lire Else MsgBox "INSERIRE PRIMA LA CIFRA NEL CAMPO PREZZO" Option2 = False End If End Sub
ma se clicco prima su euro e poi nuovamente su lire non mi da lo stesso risultato, sicuramente per colpa degli arrotondamenti vero??
grazie mille spero che puoi aiutarmi
prova questo:
codice:Private Sub Command1_Click() Dim euro As Double Dim i, j, sw As Integer lbl_euro.Caption = "" euro = txt_lire.Text / 1936.27 For i = 1 To Len(euro) lbl_euro.Caption = lbl_euro.Caption & Mid(euro, i, 1) If Mid(euro, i, 1) = "," Then sw = 1 If sw = 1 Then j = j + 1 If j = 3 Then Exit For Next i If Right(lbl_euro.Caption, 2) = "00" Then lbl_euro.Caption = Replace(lbl_euro.Caption, "00", "") End Sub
...Terrible warlords, good warlords, and an english song
BUG :gren:
sostituisci questa riga:
altrimenti se scrivi LIRE 19370codice:If Right(lbl_euro.Caption, 3) = ",00" Then lbl_euro.Caption = Replace(lbl_euro.Caption, ",00", "")
ti restituisce EURO 10,
...Terrible warlords, good warlords, and an english song
Inanzitutto grazie mille
ho provato ad adattare il tuo codice alle mie esegenze ma non va (sicuramente ho sbagliato io)
mi da errore di compilazione
lo adattato bene??codice:Private Sub Option2_Click() Dim euro As Double Dim i, j, sw As Integer prezzo.Caption = "" euro = prezzo / 1936.27 For i = 1 To Len(euro) prezzo = prezzo & Mid(euro, i, 1) If Mid(euro, i, 1) = "," Then sw = 1 If sw = 1 Then j = j + 1 If j = 3 Then Exit For Next i If Right(prezzo, 3) = ",00" Then prezzo = Replace(prezzo, ",00", "") End Sub
:bubu:
cosi non da piu errore pero ... se scrivo 150.000.000 mi ritorna 77468,53
codice:Private Sub Option2_Click() Dim euro As Double Dim i, j, sw As Integer euro = prezzo / 1936.27 For i = 1 To Len(euro) prezzo1 = prezzo1 & Mid(euro, i, 1) If Mid(euro, i, 1) = "," Then sw = 1 If sw = 1 Then j = j + 1 If j = 3 Then Exit For Next i If Right(prezzo1, 3) = ",00" Then prezzo1 = Replace(prezzo1, ",00", "") prezzo = prezzo1 End Sub