Solved

How to use VC structures and pointers in VB

Posted on 1999-01-28
3
193 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month5 days, 7 hours left to enroll

626 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