(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-03-24 06:44 AM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - Let's Rant about Visual Basic! New poll | |
Pages: 1 2 3 4Add to favorites | Next newer thread | Next older thread
User Post
||bass
Administrator








Since: 11-17-05
From: Salem, Connecticut

Last post: 6284 days
Last view: 6283 days
Posted on 01-31-07 04:50 AM Link | Quote
Originally posted by Kyoufu Kawa
To finally lay the "no pointers in VB" crap to rest, here's an excerpt from Win32 API Programming with Visual Basic I found in my copy of MSDN. I've marked the important part, StrPtr. There's also VarPtr and possibly a third.
Translating Between Byte Arrays and BSTRs
To copy a BSTR:

Dim s As String

to a byte array, we can proceed in a couple of different ways. For a strictly VB solution, we have:

s = "help"
Dim b(1 To 8) As Byte
For i = 1 To 8
b(i) = AscB(MidB(s, i))
Next


Another approach is:

s = "help"
Dim b(1 To 8) As Byte
CopyMemory b(1), ByVal StrPtr(s), LenB(s)


Note that (in both cases) we get:

104 0 101 0 108 0 112 0

showing that the bytes are reversed in each Unicode integer.
Possibly a third? Therein lies the problem. These 'pointers' from the examples look more like specialized pointer-like objects that simply capture the general-esque functionality of true pointers for specific cases. I still fail to see actual pointer support in the language specification itself. (Actual support being something other than what amounts to what appear to be little more than wrapper objects.)


(edited by ||bass on 01-30-07 10:50 PM)
Guy Perfect









Since: 11-18-05

Last post: 6285 days
Last view: 6283 days
Posted on 01-31-07 09:21 AM Link | Quote
Pointer support has always been limited in Microsoft variants of BASIC, but they really clamped down on it when they introduced Visual Basic.

Back in the days of QBASIC, there were the PEEK function and POKE statement, which could retrieve a byte from memory and write a byte to memory, respectively. Those procedures have since gone the way of Bill Clinton's credibility.

The only thing in VB nowadays, leastways with VB6 (VB.NET isnt' my specialty) are very specific "obtain a pointer value only" functions and no ability to write data to memory. The following things exist in VB6:

VarPtr Function - Retrieves the address of a variable. Was only available as a DLL import in VB4, but was later added to the IDE with VB5. Example: "X = VarPtr(Y)"

AddressOf Operator - Added in VB5 for support with various API calls. It's essentially a function for a procedure name that returns the function pointer of the given procedure. Provided for use with callbacks. Example: "ErrCode = apiUseCallback(AddressOf SomeKindaFunction)"
Pages: 1 2 3 4Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - Let's Rant about Visual Basic! |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.009 seconds; used 348.27 kB (max 411.64 kB)