473,385 Members | 1,292 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Question on Numeric Formating...

Hi there,

I'm building an application with ADO.NET and VB.NET.
This is the issue that I have right now;
I'm using this code with a data reader to populate a form from a database
(sqlServer, MSDE)

*****************
Dim us as New CultureInfo("en-US")
txtTestPrice.Text() = drSQL.Item("Price").ToString()
******************

I'm trying to convert this string into a curreny format type and I'm not
having any luck on this one.
I'm importing the System.Globalization namespace.
it gives an error when I do this

txtTestPrice.Text() = drSQL.Item("Price").ToString("c", us)
Error - Public Overridable Function ToString() As String' has no parameters
and it's return type cannot be indexed.

Can anybody out there help out on this one? Please!
Thanks very much for your help on this matter.
Manny.


Nov 20 '05 #1
5 904
That is because a datareader's Item property returns an obj. And the object
class does not have a ToString function with any parameters. Hence, you need
to either use the GetDecimal method (or whatever is appropriate) and then
call ToString on that, or cast what you get from Item to a Decimal, and then
call ToString.

"Manuel Canas" <mc*****@hotmail.com> wrote in message
news:pf%Bc.14502$mm3.13319@clgrps13...
Hi there,

I'm building an application with ADO.NET and VB.NET.
This is the issue that I have right now;
I'm using this code with a data reader to populate a form from a database
(sqlServer, MSDE)

*****************
Dim us as New CultureInfo("en-US")
txtTestPrice.Text() = drSQL.Item("Price").ToString()
******************

I'm trying to convert this string into a curreny format type and I'm not
having any luck on this one.
I'm importing the System.Globalization namespace.
it gives an error when I do this

txtTestPrice.Text() = drSQL.Item("Price").ToString("c", us)
Error - Public Overridable Function ToString() As String' has no parameters and it's return type cannot be indexed.

Can anybody out there help out on this one? Please!
Thanks very much for your help on this matter.
Manny.


Nov 20 '05 #2
Hi Marina,

Could you give you kind advice on code? I confess, I'm new to the .net
technology and I just know how to instantiate the getdecimal or cast the
item to decimal and the call tostring on that.

Thanks for your kind help.

Manny.

"Marina" <so*****@nospam.com> wrote in message
news:Og**************@TK2MSFTNGP12.phx.gbl...
That is because a datareader's Item property returns an obj. And the object class does not have a ToString function with any parameters. Hence, you need to either use the GetDecimal method (or whatever is appropriate) and then
call ToString on that, or cast what you get from Item to a Decimal, and then call ToString.

"Manuel Canas" <mc*****@hotmail.com> wrote in message
news:pf%Bc.14502$mm3.13319@clgrps13...
Hi there,

I'm building an application with ADO.NET and VB.NET.
This is the issue that I have right now;
I'm using this code with a data reader to populate a form from a database (sqlServer, MSDE)

*****************
Dim us as New CultureInfo("en-US")
txtTestPrice.Text() = drSQL.Item("Price").ToString()
******************

I'm trying to convert this string into a curreny format type and I'm not
having any luck on this one.
I'm importing the System.Globalization namespace.
it gives an error when I do this

txtTestPrice.Text() = drSQL.Item("Price").ToString("c", us)
Error - Public Overridable Function ToString() As String' has no

parameters
and it's return type cannot be indexed.

Can anybody out there help out on this one? Please!
Thanks very much for your help on this matter.
Manny.



Nov 20 '05 #3
Try this:
txtTestPrice.Text() = Ctype(drSQL.Item("Price"), Decimal).ToString("c", us)

Nov 20 '05 #4
Thanks Rulin!!!!!

So much Appreciated

Manny.

"Rulin Hong" <Ru*******@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
Try this:
txtTestPrice.Text() = Ctype(drSQL.Item("Price"), Decimal).ToString("c", us)

Nov 20 '05 #5
Hi Manual,
Are you sure that the dr.item("Price") is retrieving a numeric field?
what happens if you
txtTestPrice.Text()=ctype(dr.item("Price"),double) .toString("c", us)
regards
Bob
Manuel Canas wrote:
Hi there,

I'm building an application with ADO.NET and VB.NET.
This is the issue that I have right now;
I'm using this code with a data reader to populate a form from a database
(sqlServer, MSDE)

*****************
Dim us as New CultureInfo("en-US")
txtTestPrice.Text() = drSQL.Item("Price").ToString()
******************

I'm trying to convert this string into a curreny format type and I'm not
having any luck on this one.
I'm importing the System.Globalization namespace.
it gives an error when I do this

txtTestPrice.Text() = drSQL.Item("Price").ToString("c", us)
Error - Public Overridable Function ToString() As String' has no parameters
and it's return type cannot be indexed.

Can anybody out there help out on this one? Please!
Thanks very much for your help on this matter.
Manny.


--
Please take out the garbage before using reply address.

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: 2mc | last post by:
Generally speaking, if one had a list (from regular Python) and an array (from Numerical Python) that contained the same number of elements, would a While loop or a For loop process them at the...
32
by: David | last post by:
Hi I'm trying to teach myself python and so far to good, but I'm having a bit of trouble getting a function to work the way I think it should work. Right now I'm taking a simple program I wrote in...
0
by: vidhya subramainan | last post by:
pls, send me the coding regarding displaying the value as date, numeric values. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
1
by: Sascha Kerschhofer | last post by:
Hi, is it against the spec to import two external schemas with the same namespace into one main schema? e.g <xs:import namespace="http://myCompany.com/formating" schemaLocation="srt3.xsd"/>...
1
by: thechaosengine | last post by:
Hi all, I'm trying to format a date in a bound datagrid. In order to do this I've placed the following as an attribute to the bound column in question: DataFormatString="{0:dd/mm/yyyy}" ...
2
by: just_me | last post by:
Hello, I'd like to ask if anyone knows the format /category/13/ where probably 13 is the ID if it's actually a directory/file and a script automatically created it when someone updated his site...
0
by: Fonix | last post by:
I'm trying to make table border with pyExcelerator. As i can see there is only cell formating!? If i'm wrong pls tell me what is method to make more then one cell to have same format, other then...
2
by: sitko | last post by:
Hi, I'm in the process of converting a VB.net program into a C program so it can run on a unix like machine. I've been moving along at a nice pace, but this conversion has stumped me. I need...
6
by: sitko | last post by:
Hi, I've continued with my VB->C conversion, and have it working on the Linux box, now I'm going back and getting it to work on the Windows box. Something strange occurred and I thought I'd...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.