Jump to content

Recommended Posts

Posted (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

8BFHuEv.jpg?1

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 by FusionPwN

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.