![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Not a user?
Join Date: Sep 2007
Posts: 272
Rep Power: 2
![]() |
Visual Basic pointers
Ok, I know that when passing variables to functions, you can either pass by value or pass by reference. Does this mean that VB uses pointers like C and C++ except that it's abstracted to prevent programmer errors?
|
|
|
|
|
|
#2 |
|
Hobbyist Programmer
|
Re: Visual Basic pointers
yes, it is considered unsafe code since .NET uses its special garbage collector to free up memory and pointers fall outside the scope of the garbage collector.
in C# however there is a way to use pointers, but its not common. http://www.c-sharpcorner.com/UploadF...sInCSharp.aspx
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
|
|
#3 | ||
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 549
Rep Power: 4
![]() |
Re: Visual Basic pointers
Quote:
Quote:
__________________
True Terror is to wake up one morning and discover that your high school class is running the country - Kurt Vonnegut Jr. |
||
|
|
|
|
|
#4 |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
Re: Visual Basic pointers
I'm not entirely sure how the language is implemented, but I think it works similarly to C#'s ref keyword. If you have
Sub Foo(ByVal bar as SomeType) you can modify the contents of the SomeType object locally scoped as bar; since it's the same object as the calling function, these changes would go back. If you make bar point to a new object, then the corresponding variable in the caller will not be affected. If, on the other hand, you have Sub Foo2(ByRef bar2 as SomeType) then any changes to what object bar2 points at or its contents will affect the caller's variable as well.<reiteration of disclaimer>I'm not positive that this is how it works, and I'm too lazy to write an app to check, but that's how I'd guess it works</reiteration>
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> Last edited by Jimbo; Jul 10th, 2008 at 10:37 AM. |
|
|
|
|
|
#5 | |
|
Hobbyist Programmer
|
Re: Visual Basic pointers
Quote:
check the link I put up there quote: "The C# statements can be executed either as in a safe or in an unsafe context. The statements marked as unsafe by using the keyword unsafe runs out side the control of Garbage Collector. Remember that in C# any code involving pointers requires an unsafe context. " question #2: I disagree that it is completely irrelevant, that's my opinion. I give a damn because they are very similar langauges, they both run on the .NET Framework and often if you have a career programming in one there is a good chance you will use the other at times as well. often controls written in one langauge of the .NET framework are not available in the other, so what do you do? I've had lots of times where I use C# assembly within a VB .NET app That's why this was brought into the conversation. extra information is not always a bad thing, if i'm wrong, correct me but please go into detail so that I and others may learn from my mistakes.
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt |
|
|
|
|
|
|
#6 | |
|
Not a user?
Join Date: Sep 2007
Posts: 272
Rep Power: 2
![]() |
Re: Visual Basic pointers
Quote:
|
|
|
|
|
|
|
#7 | |
|
PFO God In Training
![]() Join Date: Jun 2005
Location: near St Louis, MO. (USA)
Posts: 549
Rep Power: 4
![]() |
Re: Visual Basic pointers
Quote:
__________________
True Terror is to wake up one morning and discover that your high school class is running the country - Kurt Vonnegut Jr. |
|
|
|
|
|
|
#8 |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Dry west coast of Canada
Posts: 1,034
Rep Power: 5
![]() |
Re: Visual Basic pointers
Don't forget that most of the similarities mentioned are between C# and VB.NET, not legacy VB.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
#9 | |
|
Battle Programmer
Join Date: Feb 2006
Location: Bellevue, WA, USA
Posts: 763
Rep Power: 3
![]() |
Re: Visual Basic pointers
Quote:
Regarding pointers, a lot of their benefit is inherent in C# and VB.NET. Note that you don't actually get a pointer, but it's more like a "safe" pointer: most of the powerful features, but less ways to blow up your program.
__________________
<insert disclaimer here> <insert shameless plug for Visual Studio here> |
|
|
|
|
|
|
#10 | |
|
Hobbyist Programmer
|
Re: Visual Basic pointers
Quote:
-do not realize VB and VB .NET are very different. -are scared of learning a somewhat unique syntax that doesn't quite stick as much to other langauge syntax (curly braces, dim, ordering of type declaration and variable name, etc) VB .NET and C# are very close, most of the differences are syntactical, I switch back and forth at work constantly from one to the other and I have to say that in a lot of cases VB .NET is my preference, people struggle with the unique syntax of it but once you know it, it has a lot of very nice things like "isnumeric" and "my" that C# doesn't have. but these are just conveniences, there are usually always ways to do whatever you need to do even without these conveniences in the other langauge. VB .NET or C# it all comes down to MSIL in the end. C# is not faster than VB .NET as some people claim.
__________________
I have never let my schooling interfere with my education. -Mark Twain- Xbox live gamertag: melbolt Last edited by melbolt; Jul 16th, 2008 at 3:28 PM. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Visual Basic to java HELP! | araujo2nd | Visual Basic .NET | 1 | Feb 13th, 2008 9:36 AM |
| File Mapping in Visual Basic? | bmad6 | Visual Basic .NET | 4 | May 16th, 2006 9:37 PM |
| want to learn Visual Basic | eax | Visual Basic | 14 | May 1st, 2006 12:12 PM |
| visual basic pixel image comparison | youngnoviceinneedofhelp | Visual Basic | 3 | Mar 19th, 2006 1:57 PM |
| Enquiry About Visual Basic Project | kbkhoo5053 | Visual Basic | 13 | Feb 15th, 2005 2:20 AM |