473,406 Members | 2,281 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,406 software developers and data experts.

How to convert a Double type to an SQLMoney type

I am trying to set Public overridable CreditlimitS() as
System.Data.SqlTypes.SqlMoney to Creditlimit as Double
like CreditLimitS=creditlimit
and get this error "Value of type double cannot be converted to
System.Data.SqlTypes.SqlMoney "
How do I get creditlimit into creditlimitS?
There seems to be no conversion function.
TIA
Nov 21 '05 #1
3 7694

Hello Peter,

I read my sql money types in a VB.Net Decimal datatype
regards

M. Posseth
"PeterK" <p.*****@verizon.net> wrote in message
news:Ot**************@TK2MSFTNGP09.phx.gbl...
I am trying to set Public overridable CreditlimitS() as
System.Data.SqlTypes.SqlMoney to Creditlimit as Double
like CreditLimitS=creditlimit
and get this error "Value of type double cannot be converted to
System.Data.SqlTypes.SqlMoney "
How do I get creditlimit into creditlimitS?
There seems to be no conversion function.
TIA

Nov 21 '05 #2
Sorry, M, I do not see the solution yet.
This case is about assigning a double variable (i.e. creditlimit) to an
SQLMoney type (creditlimitS), i.e. I cannot choose my destination data type
because that data base (class) exists, and I cannot choose the source data
type because it exists. So I have to somehow convert.
PeterK

"m.posseth" <mi*****@nohausystems.nl> wrote in message
news:eu**************@TK2MSFTNGP12.phx.gbl...

Hello Peter,

I read my sql money types in a VB.Net Decimal datatype
regards

M. Posseth
"PeterK" <p.*****@verizon.net> wrote in message
news:Ot**************@TK2MSFTNGP09.phx.gbl...
I am trying to set Public overridable CreditlimitS() as
System.Data.SqlTypes.SqlMoney to Creditlimit as Double
like CreditLimitS=creditlimit
and get this error "Value of type double cannot be converted to
System.Data.SqlTypes.SqlMoney "
How do I get creditlimit into creditlimitS?
There seems to be no conversion function.
TIA


Nov 21 '05 #3
PeterK,
In addition to the other comments:

You can use the Conversion Operators the SqlMoney defines to convert to/from
Decimal & SqlMoney along with the Conversion operators that VB defines to
convert to/from Decimal & Double.

http://msdn.microsoft.com/library/de...rsionTopic.asp

http://msdn.microsoft.com/library/de...rsionTopic.asp

The "problem" is that VB 2002 & 2003 do not normally see the above
conversion operators. You need to use "Tools - Options - Text Editor -
Basic - General - Hide Advanced members" to show or hide the above advance
members. Once the above members are shown, you can use Intellisense on them.

Something like:

Dim money As SqlTypes.SqlMoney
Dim dollar As Double

money = SqlTypes.SqlMoney.op_Implicit(CDec(dollar))
dollar = SqlTypes.SqlMoney.op_Explicit(money)

VB 2005 (aka Whidbey, due out Nov 7th 2005) will have full support for
overloading conversion operators, so the above two methods will work with
CType!

Something like (untested):

' VB 2005 syntax
Dim money As SqlTypes.SqlMoney
Dim dollar As Double

money = dollar
dollar = CDec(money)

' alternatively you can use CType directly
money = CType(dollar, SqlTypes.SqlMoney)
dollar = CType(money, Double)

NOTE: I have not tested the above, you may need to convert to/from Decimal
first, then explicitly convert to/from Decimal & Double. I don't remember if
it allows two implicit conversions in a row (SqlMoney to Decimal, then
Decimal to Double). In other words you may need:

money = CType(CType(dollar, Decimal), SqlTypes.SqlMoney)
- or -
money = CType(CDec(dollar), SqlTypes.SqlMoney)

Remember that CDec(?) is short hand for CType(?, Decimal).

Hope this helps
Jay

"PeterK" <p.*****@verizon.net> wrote in message
news:Ot**************@TK2MSFTNGP09.phx.gbl...
|I am trying to set Public overridable CreditlimitS() as
| System.Data.SqlTypes.SqlMoney to Creditlimit as Double
| like CreditLimitS=creditlimit
| and get this error "Value of type double cannot be converted to
| System.Data.SqlTypes.SqlMoney "
| How do I get creditlimit into creditlimitS?
| There seems to be no conversion function.
| TIA
|
|
Nov 21 '05 #4

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

Similar topics

0
by: Chris B. | last post by:
SqlMoney is not serializable and it is sealed to prevent creating a serializable child class. That seems like a waste of a perfectly useful datatype that could have been a member of internal...
2
by: Pascal | last post by:
Why does this not work, and how should i do this convert in stead: string x = double.MinValue.ToString(); double y = Convert.ToDouble(x); i get this exception: An unhandled exception of type...
2
by: jiangyh | last post by:
hi there : I have a question about how to convert Type to DbType? thanks a lot. jiangyh
17
by: David Scemama | last post by:
Hi, I'm writing a program using VB.NET that needs to communicate with a DOS Pascal program than cannot be modified. The communication channel is through some file databases, and I have a huge...
3
by: Eric BOUXIROT | last post by:
hi, i must convert all of these eVC++ prototypes to use with VB.NET.... DLLEXPORT long F_BDO_MessageBoxOK(char *IN_title, char *IN_msg ); DLLEXPORT long F_BDO_MessageBoxOUINON(char *IN_title,...
28
by: MLH | last post by:
The largest integer A97 can deal with is 2,147,483,647, as I understand it from HELP. I would be content to represent larger integers as strings. For example, "2147483648" would suit me fine. I...
4
by: a.frank81 | last post by:
I have problems with this Code: Public Sub SetPropertyValue(ByVal strPropertyPath As String, ByVal obj As Object, ByVal Value As Object) ..... Dim t_PropertyInfos() As...
3
by: rishabhshrivastava | last post by:
Hello All, How can I convert a value to Double in JavaScript??? In vbscript i believe its done as cDbl(Value) I tried lots of way but getting a value of "NaN". Any suggestions/ideas will...
3
by: mrajanikrishna | last post by:
Hi Friends, I am accepting a number from the user entered in a textbox. I want to assign to a variable in my code and assignt this to that variable. double num1 = (double)txtNum1.text; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.