FusionPwN Posted June 2, 2014 at 07:19 PM Report #557960 Posted June 2, 2014 at 07:19 PM (edited) Boas, estou com um problema na formatação de um valor numa textbox, preciso mesmo que este valor so tenha 2 casas decimais, já tentei varios metodos de formatação e dá sempre asneira... Preciso que este valor sublinhado fique só com 2 casas decimais O valor desta textbox e dado por esta linha de código: TextBox2.Text = lercod1("PRECO") * Label4.Text Dim num1 As Decimal Dim num2 As Decimal Dim iva1 As Decimal Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click If TextBox1.Text = "" Then MsgBox("", MsgBoxStyle.Exclamation, "") ElseIf IsNumeric(TextBox1.Text) = False Then MsgBox("Deve ser inserido apenas numeros!", MsgBoxStyle.Exclamation, "Apenas Numeros") ElseIf TextBox1.Text.Length < 13 Then MsgBox("", MsgBoxStyle.Exclamation, "Digitos em Falta") ElseIf TextBox1.Text.Length > 13 Then MsgBox("", MsgBoxStyle.Exclamation, "Digitos a mais") Else Try con.Open() cmd.Connection = con cmd.CommandText = "SELECT CODBARRAS,NOMEJOGO,STOCK,PRECO FROM jogos WHERE CODBARRAS = '" & TextBox1.Text & "'" cmd.ExecuteNonQuery() Dim lercod1 As MySqlDataReader = cmd.ExecuteReader If lercod1.HasRows = 0 Then MsgBox("Não foi encontrado nenhum registo!", MsgBoxStyle.Exclamation, "Não há registos!") Else TextBox1.Enabled = False lercod1.Read() Label8.Text = lercod1("NOMEJOGO") Label8.Visible = True Label10.Text = lercod1("STOCK") Label10.Visible = True TextBox3.Text = lercod1("PRECO") TextBox2.Text = lercod1("PRECO") * Label4.Text num1 = TextBox3.Text num2 = TextBox2.Text iva1 = num1 + num2 TextBox4.Text = iva1 TextBox4.Text = Math.Round(iva1, 2) 'MsgBox("Registo encontrado com sucesso!", MsgBoxStyle.Information, "Registo Encontrado") End If Catch ex As Exception MsgBox(ex.ToString) Finally con.Close() End Try End If End Sub Edited June 2, 2014 at 07:25 PM by FusionPwN
nelsonr Posted June 2, 2014 at 08:41 PM Report #557976 Posted June 2, 2014 at 08:41 PM Boas, experimenta com algo assim TextBox2.Text = Convert.ToDecimal(lercod1("PRECO") * Label4.Text).ToString("#0.00") 1 Report
FusionPwN Posted June 2, 2014 at 09:19 PM Author Report #557989 Posted June 2, 2014 at 09:19 PM Boas, experimenta com algo assim TextBox2.Text = Convert.ToDecimal(lercod1("PRECO") * Label4.Text).ToString("#0.00") Muito Obrigado resolvido 😄
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now