Solved

How to use VC structures and pointers in VB

Posted on 1999-01-28
3
192 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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Run code from text file in vb 1 103
Problem to With line 4 87
which modules are active in VB6 project? 6 57
Macro problems with Excel file 6 53
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…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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…

710 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