Seven price
asked on
Format in vb
Yes i am trying to use format where once i add a numeric number for example.
3 when i add 3 in my form it will got to my datagrid and display 3.0
but if a user adds 3.0 it will just display 3.0
3 when i add 3 in my form it will got to my datagrid and display 3.0
but if a user adds 3.0 it will just display 3.0
prm = New SqlParameter("@Price", SqlDbType.Decimal)
prm.Direction = ParameterDirection.Input
prm.Value = String.Format(Me.Price.Text, "##.00")
'Me.Price.Text = Decimal.Round(Me.Price.Text, 0.0).ToString()
cmd.Parameters.Add(prm)
Change your format "xx.oo" to "xx.x"
ASKER
are you talking abou this
prm.Value = String.Format(Me.Price.Tex t, "##.00")
prm.Value = String.Format(Me.Price.Tex
ASKER
well i change prm.Value = String.Format(Me.Price.Tex t, "##.00") to
prm.Value = String.Format(Me.Price.Tex t, "00.0")
but i only get the value if i put prm.Value = String.Format("0.00") but that would only display the value of 0
I even tried Convert.ToDecimal nothing is working. anything else then i can get out of your hair.
prm.Value = String.Format(Me.Price.Tex
but i only get the value if i put prm.Value = String.Format("0.00") but that would only display the value of 0
I even tried Convert.ToDecimal nothing is working. anything else then i can get out of your hair.
ASKER
maybe this will help clarify similar to this problem
https://www.experts-exchange.com/questions/21038093/Using-Format-function.html
https://www.experts-exchange.com/questions/21038093/Using-Format-function.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok i am a newbie at this and I have no idea what ou wrote here
What is your specific application?
ASKER
windows, asp.net visual basic, windows forms, visual studio 2003, 1.1 frameworks
prm.Value = String.Format(Me.Price.Tex t, "##.0")
ASKER
it displays but with out the decimal, for example if i put 33 it will come up 33 not 33.0 but now errors.
ASKER
no errors excuse the english
By using the .00 you are asking for two decimal places. What happens if you do "xx.x" instead?
ASKER
I understand the # as a place holder and i tried it but it gives me the value i put inside the text box but thats it.
prm = New SqlParameter("@Price", SqlDbType.Decimal)
prm.Direction = ParameterDirection.Input
prm.Value = String.Format(Me.Price.Text, "xx.x")
cmd.Parameters.Add(prm)
ASKER
i tried all thes formats also still returns 3 instead of 3.0 or 3.00
prm = New SqlParameter("@Price", SqlDbType.Decimal)
prm.Direction = ParameterDirection.Input
'prm.Value = String.Format(Me.Price.Text, "xx.x")
'prm.Value = String.Format(Left(Me.Price.Text, "##.00"))
prm.Value = String.Format("{0:D}", Me.Price.Text)
'Format(Left(Me.Price.Text, 4), "##.00"
'prm.Value = Format(me.Price.text, "00.0")
'Me.Price.Text = Decimal.Round(Me.Price.Text, 0.0).ToString()
I am not sure what you are saying? Please give an example.
ASKER
if you see in the iimage the price is just 3 but in the other image its 1.89 because i added 1.89 but i need the 3 to be 3.0 when added
ScreenHunter-01-Jan.-29-12.28.gif
ScreenHunter-01-Jan.-29-12.28.gif
ASKER
ok so the add parameter is not going to work because this is adding what i am thinking we have to style this when it is bounded already within the datagrid. So on the front end within the datagrid we have to change the format within the datagrid when the information is there already. what you think.
<asp:/BoundColumn DataField="price" >
</bound>
<asp:/BoundColumn DataField="price" >
</bound>
ASKER
Ok to do this I found out such a easier way.
On the Datagird and the tables you have to the Templatecolmn
use the boundcolumn DataFormatString="{0:N}" or any formatt you like to display .
Thanks for trying
On the Datagird and the tables you have to the Templatecolmn
use the boundcolumn DataFormatString="{0:N}" or any formatt you like to display .
Thanks for trying
ASKER
Ok to do this I found out such a easier way.
On the Datagird and the tables you have to the Templatecolmn
use the boundcolumn DataFormatString="{0:N}" or any formatt you like to display .
Thanks for trying
On the Datagird and the tables you have to the Templatecolmn
use the boundcolumn DataFormatString="{0:N}" or any formatt you like to display .
Thanks for trying