473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

How to upgrade Objptr function from VB6 to VB2005

t
In VB6, I usually use objptr function and API copymemory to identify and
obtain an object, how can I convert them into VB2005? Your kindly help would
be much appreciated.

Dec 12 '05 #1
8 6837
Hi,

http://www.planet-source-code.com/vb...=463&lngWId=10

Ken
----------------
"t" <qi*********@szywp.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
In VB6, I usually use objptr function and API copymemory to identify and
obtain an object, how can I convert them into VB2005? Your kindly help
would
be much appreciated.

Dec 12 '05 #2
T,

A better way than upgrading them is to look what Net alternatives there are
for the API for what you need it.

http://msdn.microsoft.com/library/de...l/win32map.asp

At least it can help you when WinFx becomes the standard.

I hope this helps,

Cor

"t" <qi*********@szywp.com> schreef in bericht
news:%2****************@TK2MSFTNGP14.phx.gbl...
In VB6, I usually use objptr function and API copymemory to identify and
obtain an object, how can I convert them into VB2005? Your kindly help
would
be much appreciated.

Dec 12 '05 #3
"t" <qi*********@szywp.com> schrieb:
In VB6, I usually use objptr function and API copymemory to identify and
obtain an object, how can I convert them into VB2005? Your kindly help
would
be much appreciated.


I suggest to describe the scenario in more detail. There are maybe plenty
of alternative solutions which are preferrable over the 'CopyMemory'
solution.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 12 '05 #4
t
Hi,
I would like to describe my application here, pls kindly read through
it.
In my app, I have 2 classes QRecord and QRecords, and class QRecords is
a collection of class QRecord. Codes are listed below.

1.Code of QRecord
Private mvarParentPointer As Variant
Public Function GetParent() As QRecords
Dim oTemp As Object

'********************************************
CopyMemory oTemp, mvarParentPointer, 4
'*********************************************

Set GetParent = oTemp
CopyMemory oTemp, 0&, 4
End Function

Friend Property Let ParentPointer(ByVal vData As Variant)
mvarParentPointer = vData
End Property
Friend Property Set ParentPointer(ByVal vData As Variant)
Set mvarParentPointer = vData
End Property

2.Code of QRecords
Private mCol As Collection

Public Function Add(Optional sKey As String) As QRecord
Dim objNewMember As QRecord
Set objNewMember = New QRecord

'************************************************* **********
objNewMember.ParentPointer= ObjPtr(Me)
'************************************************* **********

If Len(sKey) = 0 Then
mCol.Add objNewMember
Else
mCol.Add objNewMember, sKey
End If

Set Add = objNewMember
Set objNewMember = Nothing

End Function

Public Property Get Item(vntIndexKey As Variant) As QRecord
Set Item = mCol(vntIndexKey)
End Property

Public Property Get Count() As Long
Count = mCol.Count
End Property
Public Sub Remove(vntIndexKey As Variant)
mCol.Remove vntIndexKey
End Sub

Public Property Get NewEnum() As IUnknown
Set NewEnum = mCol.[_NewEnum]
End Property
Private Sub Class_Initialize()
Set mCol = New Collection
End Sub
Private Sub Class_Terminate()
Set mCol = Nothing
End Sub
QRecord have a pointer to it parent without counting reference to
QRecords, so that instance of QRecords can be destroyed when it is set to
nothing, no need to enumerate all QRecord items and set them to nothing one
by one in case QRecord has an attribute of QRecords referencing it parent
dirrectly.

Hope I am understood and able to get your help. Thanks in advanced.
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> ????
news:%2***************@TK2MSFTNGP15.phx.gbl...
"t" <qi*********@szywp.com> schrieb:
In VB6, I usually use objptr function and API copymemory to identify and
obtain an object, how can I convert them into VB2005? Your kindly help
would
be much appreciated.


I suggest to describe the scenario in more detail. There are maybe plenty
of alternative solutions which are preferrable over the 'CopyMemory'
solution.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Dec 13 '05 #5
"t" <qi*********@szywp.com> schrieb
QRecord have a pointer to it parent without counting reference to
QRecords, so that instance of QRecords can be destroyed when it is
set to nothing, no need to enumerate all QRecord items and set them
to nothing one
by one in case QRecord has an attribute of QRecords referencing it
parent dirrectly.

In .Net, we don't have reference counts anymore like in VB6/COM. We can now
make circular references without worrying about "lost" objects referencing
each other. Have the QRecord point to the QRecords collection and everything
is fine. When you delete the last reference to the collection, the GC
(garbage collector) will clean the collection and it's items (when it's time
to) even if they reference each other.
Armin

Dec 13 '05 #6
"Armin Zingler" <az*******@freenet.de> schrieb
... the GC
(garbage collector) will clean the collection and it's items (when
it's time to) even if they reference each other.

see also:

http://msdn.microsoft.com/library/en...management.asp
(also available via F1)
Armin

Dec 13 '05 #7
How to get a pointer to the form???

In VB 6, It is like objPtr(formname)...This wil return memory address of d form.
In VB.net how it acn be done?

From http://www.developmentnow.com/g/38_2...-to-VB2005.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Mar 13 '07 #8
"sanitha" <no****@developmentnow.comschrieb:
How to get a pointer to the form???

In VB 6, It is like objPtr(formname)...This wil return memory address of d
form.
In VB.net how it acn be done?
You still should describe what you want to archieve with the pointer.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Mar 13 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Brett | last post by:
I have a C# project created in VS.NET 2003. I tried to run it in VS.NET 2005. 2005 did a conversion. I see much VB code and VB style comments. I don't know what it did. Will a 2003 C# project...
23
by: Dennis Sjogren | last post by:
Hi! I have this medium sized solution with a couple of projects and stuff. The generated application has an <appname>.exe.manifest file to enable XP themes. In the main window of the application...
13
by: Andy | last post by:
Hi As I try to learn VB programing I've been playing around with sourcecode from projects hosted on sourceforge. If I open this code in VB 2005 (it is originally developed in VB 2003), it will...
1
by: Tosco | last post by:
I need to upgrade from vb6 to vb2005 an application that uses a WebBrowser control and some api to do this: Dim PageText As String Sub Main WebBrowser.Navigate URL End Sub Sub...
1
by: erickwan88 | last post by:
I am doing a final year project for my school and is going to provide for an organization, so I am asking for some help on here. Indeed, I have no idea on how to get the input from my pen driver...
1
by: sani | last post by:
How to upgrade Objptr function from VB6 to VS.net 2003 From http://www.developmentnow.com/g/38_2005_12_0_12_0/dotnet-languages-vb.htm Posted via DevelopmentNow.com Groups...
1
by: Vae07 | last post by:
Ok so here is a brief summary of my problem. I need a pop up form that submits input text box information to a pocket excel workbook upon a command botton click. Text box inputs are checked for...
9
by: MichaelH | last post by:
Are there any definite advantages of VB2008 over VB2005? Thank in advance. Michael
5
by: Wal | last post by:
Is it possible to upgrade vb6 code snippets in vb 2008 Express? I get "The System cannot find the file specified" even though I have installed all available options.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.