Hello
Everything in .Net is an object and CTYPE converts one datatype to another
datatype so why use Cstr, Cint or any other method to convert from one
datatype to another? 8 5167
"winlin" <wi****@verizon.comschrieb
Hello
Everything in .Net is an object and CTYPE converts one datatype to
another datatype so why use Cstr, Cint or any other method to
convert from one datatype to another?
Because it's shorter. "CInt(s)" is shorter than "CType(s, Integer)"
Armin
Hello
Everything in .Net is an object and CTYPE converts one datatype to another
datatype so why use Cstr, Cint or any other method to convert from one
datatype to another?
For backwards compatibility or for those who prefer to write in vb6 style.
-h-
winlin wrote:
Hello
Everything in .Net is an object and CTYPE converts one datatype to another
datatype so why use Cstr, Cint or any other method to convert from one
datatype to another?
For when you want to do one kind of conversion, but not allow another.
There are several different ways of converting values, and they all fit
in different situations.
CType(stringValue, Integer) will for example convert a null string into
zero, but that is not always desirable. Sometimes you want a null value
to be considered illegal, and not silently converted.
Another example is casting of a known type. The DirectCast method is a
slightly faster, and it will only allow casting a reference into it's
actual type.
--
Göran Andersson
_____ http://www.guffa.com
"Heikki Leivo" <he************@cadworksdotfi.removethisschrieb
Hello
Everything in .Net is an object and CTYPE converts one datatype to
another datatype so why use Cstr, Cint or any other method to
convert from one datatype to another?
For backwards compatibility or for those who prefer to write in vb6
style.
Why is using the shorter, straight version "vb6 style"? These are all
commands, specialized on the destination type, that are even compiled
inline.
Armin
CType(x, Integer) is identical to CInt.
They will both convert a null string to zero.
In general, CType has identical behavior to the shorter CInt, CLng, etc.
macros (they aren't functions, but part of VB language syntax).
--
David Anton http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Java
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
"Göran Andersson" wrote:
winlin wrote:
Hello
Everything in .Net is an object and CTYPE converts one datatype to another
datatype so why use Cstr, Cint or any other method to convert from one
datatype to another?
For when you want to do one kind of conversion, but not allow another.
There are several different ways of converting values, and they all fit
in different situations.
CType(stringValue, Integer) will for example convert a null string into
zero, but that is not always desirable. Sometimes you want a null value
to be considered illegal, and not silently converted.
Another example is casting of a known type. The DirectCast method is a
slightly faster, and it will only allow casting a reference into it's
actual type.
--
Göran Andersson
_____ http://www.guffa.com
Absolutely.
CType, CInt, CLng, etc. are all a legit part of VB syntax and are not
related to any legacy libraries.
--
David Anton http://www.tangiblesoftwaresolutions.com
Convert between VB, C#, C++, and Java
Instant C#
Instant VB
Instant C++
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
"Armin Zingler" wrote:
"Heikki Leivo" <he************@cadworksdotfi.removethisschrieb
Hello
Everything in .Net is an object and CTYPE converts one datatype to
another datatype so why use Cstr, Cint or any other method to
convert from one datatype to another?
For backwards compatibility or for those who prefer to write in vb6
style.
Why is using the shorter, straight version "vb6 style"? These are all
commands, specialized on the destination type, that are even compiled
inline.
Armin
David Anton wrote:
CType(x, Integer) is identical to CInt.
They will both convert a null string to zero.
Yes, of course. Other methods won't, like Int32.Parse for example.
--
Göran Andersson
_____ http://www.guffa.com
Hello! Good Site! Thanks you! uibdbmfwnwwdw This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Joeri |
last post by:
Hi,
I'm struggling with this issue, maybe someone has already
solved ik before. Here's the problem
I Have :
clsA witch is a base class
clsB inherits from clsA
clsC inherits from clsA
clsD...
|
by: Logan X via .NET 247 |
last post by:
It's official....Convert blows.
I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
|
by: Mark Kamoski |
last post by:
Hi--
What is the difference between Convert.ToString(obj) and CType(obj,
String)?
(Assume obj is a variable of type Object.)
Please advise.
Thank you.
|
by: Mike Cooper |
last post by:
There is something about inherited classes I evidently don't know...
I wrote the following class:
Class Class1
inherits System.Windows.Forms.DataGridTextBoxColumn
End Class
There is...
|
by: Ot |
last post by:
I apparently have a bit to learn about Casting and Conversion. I have been
thinking of them as the same but a discussion in another thread leads me to
believe that this is wrong thinking.
I...
|
by: John A Grandy |
last post by:
could someone please discuss the pros and cons of
CType(MyDouble,Decimal)
versus
Convert.ToDecimal(MyDouble)
.... and other such conversions ...
|
by: Brian Henry |
last post by:
is there any speed diffrences between doing Ctype or directcast? I know
about the inherite diffrences, but process usage time wise, does one take up
more cycles then the other? thanks
|
by: FB's .NET Dev PC |
last post by:
I'm trying to create a general-purpose routine to update a value in a data
location on a remote server. The client-server protocol is OPC, but that
isn't immediately important to my question. The...
|
by: Todd Plambeck |
last post by:
Is there a more C# like alternative to CType? I don't like using the
VB6esque "C" conversion methods(CStr, CInt, etc) . I'd prefer to user
something like Convert.ToInt32(), but can't find a...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: giovanniandrean |
last post by:
The energy model is structured as follows and uses excel sheets to give input data:
1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
|
by: NeoPa |
last post by:
Hello everyone.
I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report).
I know it can be done by selecting :...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
|
by: GKJR |
last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
| |