Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 21

Discussione: [VB] euro

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929

    [VB] euro

    ciao a tutti


    ma perche non mi funziona??

    codice:
    If Option2 = True Then
    lire = Round(Val(prezzo.Text) / 1936.27, 2)
    end if

  2. #2
    Prova così :

    lire = Round((Val(prezzo.Text) / 1936.27), 2)



    :bubu:

  3. #3
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    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 €



  4. #4
    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

  5. #5
    :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

  6. #6
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    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
    emm..ho sbagliato a scrivere :tongue:

    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

    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
    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)

    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


  7. #7
    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

  8. #8
    BUG :gren:

    sostituisci questa riga:
    codice:
    If Right(lbl_euro.Caption, 3) = ",00" Then lbl_euro.Caption = Replace(lbl_euro.Caption, ",00", "")
    altrimenti se scrivi LIRE 19370

    ti restituisce EURO 10,
    ...Terrible warlords, good warlords, and an english song

  9. #9
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    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

    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
    lo adattato bene??

    :bubu:

  10. #10
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    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

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.