4
And I’m having trouble properly converting this string
in decimal
.
decimal.Parse(txtValor.Text)=meuVen.Valor;
When I put the conversion in front, it shows error after the =
. I don’t know how to convert the second part, or if I should change the second part instead of the first.
The teacher’s code is:
private void Leitura2()
{
txtCod2.Text = dgvRegistros2.Rows[dgvRegistros2.CurrentRow.Index].Cells["codigo_servico"].Value.ToString();
Vendas meuVen = new Vendas(int.Parse(txtCod2.Text));
txtNome.Text = meuVen.Nome;
decimal.Parse(txtValor.Text) = meuVen.Valor;
txtEntrega.Text = meuVen.Entrega.ToString("dd/MM/yyyy");
}
You want to convert and assign to
meuVen.Valor
, that’s it?– Leonel Sanches da Silva
Unfortunately, in the school where I am, programming is very weak and these doubts with conversions have not been well explained. What happens is that in this program that I am doing I want the value that is taken from the database to be a value that I can use for calculation, because I will have a tax note that will show the total value. In the database it is already as decimal and in the other form and Cs it is already ok, the problem is being in this in detail in which I have a read button and this button reads the data taken from the database and shows in a datagridview.
– PanteraCP
The method the teacher taught was this. private void Leitura2() { txtCod2.Text = dgvRegistros2.Rows[dgvRegistros2.CurrentRow.Index]. Cells["codigo_servico"].Value.ToString();

 Vendas meuVen = new Vendas(int.Parse(txtCod2.Text));
 
 txtNome.Text = meuVen.Nome;
 decimal.Parse(txtValor.Text) = meuVen.Valor;
 txtEntrega.Text = meuVen.Entrega.Tostring("dd/MM/yyyy"); }
– PanteraCP
I’m sorry I don’t know how to edit the code here to get the formatting right. Basically I want him to read what appears in the textbox and turn to decimal so that I can use this value for a sum. Thanks for the help
– PanteraCP
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero