Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is a "Public Object Module

Status
Not open for further replies.

versof

Programmer
Aug 28, 2021
2
US
I'm trying to implement

type objpt
x as single
Y as single
end type

Here is my class

VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "Objpt"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Private mvarX As Single 'local copy
Private mvarY As Single 'local copy
Public Property Let Y(ByVal vData As Single)
mvarY = vData
End Property

Public Property Get Y() As Single
Y = mvarY
End Property

Public Property Let X(ByVal vData As Single)
mvarX = vData
End Property

Public Property Get X() As Single
X = mvarX
End Property

compilation-wise, it looks beautiful. but this simple code blows it:

Public Function PointOf(X As Single, Y As Single) As Objpt
PointOf.X = X
PointOf.Y = Y
End Function

What am I missing?
 
[tt]Public Function PointOf(X As Single, Y As Single) As Objpt
Set PointOf = New Objpt
PointOf.X = X
...[/tt]

combo
 
I thought you had it, but no. It found something else to complain about.

Public Sub VCircle(p0 As Objpt, Radius As Single, Color As Long)
Dim P As Objpt
Dim Angle As Single 'current Angle
For Angle = 0 To 360 Step 10
PolarToCartesian Radius, Angle, P
Pic.Line (p0.X, p0.Y)-(P.X, P.Y), 0 'first inter-segment boundary
Next
End Sub

is a method in the new user control based on PictureBox.

Public Sub run()
Set p0 = New Objpt
p0 = PointOf(0, 0)
pic1.SetScale 5 '5 inch picture, target scaling
pic1.VCircle p0, 2.5, 0 'centered 2.5 inch radius starburst, black
End Sub

This is my first use of the new control in my .frm that contains the new control.

The error "ByRef argument type mismatch" occurs on the last reference to p0.


 
You have not instantiated or initialised P in VCircle, so VCircle fails on the PolarToCartesian line. You need to switch to 'Break in Class Module" for your error handling (Tools -> Options -> General -> Error Trapping) to see this

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top