Jump to content

Separ números recebidos da serial

Recommended Posts

Boa noite!

Estou utilizando vb6 em uma aplicação recebendo dados da serial,os dados estáo recebendo pelo text1.text o  seguinte formato:


E preciso separar e mostrar no text2.text apenas no formato 0,14.


Link to post
Share on other sites

Bom dia,

Para duas casas decimais:

Int ( numero_a_truncar* 100 ) / 100




Se o tratamento é apenas da string no text1.text, colaca os nºs numa listbox

Dim aux As String
Dim pos, nVirg As Integer

    aux = ""
    pos = 1
    nVirg = 0
    If Len(Text1.Text) >= 5 Then
            aux = aux + Mid(Text1.Text, pos, 1)
            If Mid(aux, pos, 1) = "," Then nVirg = nVirg + 1
            pos = pos + 1
        Loop Until nVirg = 2
            Text1.Text = Mid(Text1.Text, pos - 2, Len(Text1.Text))
            aux = Mid(aux, 1, Len(aux) - 2)
            List1.AddItem (aux)
        List1.AddItem (Text1.Text)
        Exit Do
    End If

Um abraço


Edited by miglaranjeira
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.