Solved

How to use VC structures and pointers in VB

Posted on 1999-01-28
3
186 Views
Last Modified: 2010-05-03
Is there anyway in VB that you can define a String of Data (Buffer) and reference that data using a structure (Type) with a pointer?

VC Example:

struct EntryStruct
      {
      char szFldName [50];      
      int  nFldNumber;
      };


char szBuffer [500];
char szName   [100];      

EntryStruct* pPtr;
pPtr = (EntryStruct*) szBuffer;
szName = pPtr.szFldName;
0
Comment
Question by:JJONES
3 Comments
 
LVL 1

Expert Comment

by:mackagp
ID: 1471048
dunno if this helps, but you can define a fixed length string with
dim strxxx as string * 500

You can access any character in it by using

strxxy=mid(strxxx,position,1)


0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1471049
You can use RtlMoveMemory API to copy a struct into a buffer  directly, I think that will be the furthermost vb can do
Anyway, why are you asking, there might be a better way to achive what you want
0
 

Accepted Solution

by:
kuen earned 100 total points
ID: 1471050
Type EntryStruct
    szFldName(49) as Byte
    nFldNumber as Long
End Type

Dim pPtr as EntryStruct
Dim szName() As Byte
szName = pPtr.szFldName

No need to assign szBuffer, VB will do it.

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now