473,396 Members | 1,921 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,396 software developers and data experts.

Type conversion question in vb.net

Ann
Does somebody know why I get a blank string in strA?

"
Option Strict On
Option Explicit On

Public Class Cast
Private Sub FuncA()

Dim strA As String
funcB(CType(strA, Integer))
MsgBox(strA)

End Sub

Public Sub funcB(ByVal objA As Integer)
objA = 1234
End Sub

End Class

"
Jul 19 '05 #1
2 2111
You are passing it byval instead of by ref. strA never gets changes in
funca.

Byval is the preferred and default way to pass objects. What you should do
is make funcb a function that returns value back to funca

Private Sub FuncA()
Dim strA As integer
a=funcB()
MsgBox(strA.tostring())
End Sub

Public function funcB() as integer
return 1234
End function

"Ann" <wa********@yahoo.com> wrote in message
news:01****************************@phx.gbl...
Does somebody know why I get a blank string in strA?

"
Option Strict On
Option Explicit On

Public Class Cast
Private Sub FuncA()

Dim strA As String
funcB(CType(strA, Integer))
MsgBox(strA)

End Sub

Public Sub funcB(ByVal objA As Integer)
objA = 1234
End Sub

End Class

"

Jul 19 '05 #2
ann
I did try byref. but the result is the same. I believe if
use ctype in the function parameter, DotNet create a
another object instead of using the original one. --
That's why I always get NULL come back.
-----Original Message-----
You are passing it byval instead of by ref. strA never gets changes infunca.

Byval is the preferred and default way to pass objects. What you should dois make funcb a function that returns value back to funca

Private Sub FuncA()
Dim strA As integer
a=funcB()
MsgBox(strA.tostring())
End Sub

Public function funcB() as integer
return 1234
End function

"Ann" <wa********@yahoo.com> wrote in message
news:01****************************@phx.gbl...
Does somebody know why I get a blank string in strA?

"
Option Strict On
Option Explicit On

Public Class Cast
Private Sub FuncA()

Dim strA As String
funcB(CType(strA, Integer))
MsgBox(strA)

End Sub

Public Sub funcB(ByVal objA As Integer)
objA = 1234
End Sub

End Class

"

.

Jul 19 '05 #3

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

Similar topics

4
by: Mark Oliver | last post by:
Hi, I want to put a type conversion in my class, but I don't want the conversion to be usable in a passed parameter because it makes no sense. class cData { string s; public cData(string s)...
7
by: Madhu Gopinathan | last post by:
Hi, I hope this is the right forum for this question. I am extending ICollection to create a Collection Type (say MyCollection) wherein I can control the types of objects being added to the...
27
by: Yuriy Solodkyy | last post by:
Hi VS 2005 beta 2 successfully compiles the following: using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
3
by: pgconnolly | last post by:
/* foreach does implicit type conversion on elements of a params argument or Generic.List. * This is not good. * Examples of evil follow... */ using System; // I love it when C# is strict...
16
by: Enekajmer | last post by:
Hi, 1 int main() 2 { 3 float a = 17.5; 4 printf("%d\n", a); 5 printf("%d\n", *(int *)&a); 6 return 0; 7 }
2
by: Martin v. Löwis | last post by:
I've been working on PEP 353 for some time now. Please comment, in particular if you are using 64-bit systems. Regards, Martin PEP: 353 Title: Using ssize_t as the index type Version:...
1
by: lovecreatesbeauty | last post by:
There is a warning/(error? I remember it is an error for line 10 on some compilers before. At least on g++, it is an error.) for line 10. I first read a similar example from `Expert C Programming...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
4
by: zaeminkr | last post by:
I got a good answer here I have still confusing part. I have two very simple classes class DRect { private : double x0, y0, x1, y1; public : DRect(double a, double b, double c, double d) :...
8
by: Smithers | last post by:
Are there any important differences between the following two ways to convert to a type?... where 'important differences' means something more profound than a simple syntax preference of the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.