Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to use VC structures and pointers in VB

Posted on 1999-01-28
3
Medium Priority
?
194 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 200 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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…
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…
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…
Suggested Courses

705 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