|
-
Jan 21st, 2005, 07:21 AM
#1
Thread Starter
Junior Member
[RESOLVED] Class Modules and Forms
I am trying to write a DLL and the problem that I having is that I need to get the value of a string variable from form1 of a Class Module (clGetAutomationDrives) to the Class module (clGetAutomationDrives). Can anyone tell me how to do this. This is my first exposure to Class Modules. Here is the code within the Class Module (form1):
Public Function GETDRIVES_INNTGXPFS1() As String
' THIS SUBROUTINE FINDS ALL OF THE LOGICAL DRIVES AND THEN FINDS THE
' DRIVE THAT IS NAMED AUTOMATION and is 10 characters long AND RETRIEVES THE DRIVE LETTER
Dim x, y As Integer
'Search each drive for an "Automation" indication
For x = 0 To Drive1.ListCount - 1
y = InStr(1, Drive1.List(x), "Automation", 1)
If y = 18 Then
'If found, assign the drive letter and exit the routine
GETDRIVES_INNTGXPFS1 = Mid(Drive1.List(x), 1, 1)
x = Drive1.ListCount - 1
End If
Next
'GETDRIVES_INNTGXPFS1 = MAPPEDDRIVE_INNTGXPFS1
End Function
Private Sub Form_Load()
GETDRIVES_INNTGXPFS1
End Sub
Public Property Let getdriveletter(ByVal vNewValue As String)
getdriveletter = GETDRIVES_INNTGXPFS1
End Property
Here is the code in the class module (clGetAutomationDrives):
Public MAPPEDDRIVE_INNTGXPFS1 As String
Public GETDRIVES_INNTGXPFS1 As String
Public Function loadform()
Form1.Visible = True
End Function
Public Property Get getdriveletter() As String
getdriveletter = GETDRIVES_INNTGXPFS1
End Property
Here is the code in the test form to test the DLL:
Option Explicit
Private Sub Command1_Click()
Dim test As New clGetAutomationDrives
' Create the objects
Set test = New clGetAutomationDrives
MsgBox test.loadform
Debug.Print "GETDRIVES_INNTGXPFS1="; getdriveletter
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Last edited by ga80071; Jan 21st, 2005 at 03:18 PM.
Reason: Issue resolved - Thank you very much
-
Jan 21st, 2005, 09:45 AM
#2
Re: Class Modules and Forms
I can help you.
1) Place your original code in [Highlight=VB] tags, I can't read it.
2) Define, very briefly, how the Form and the Class have to interact.
ie.. The Class needs a String from the Form, or I need to pass a String from the Class to the Form. From your statements, I can't tell which you are trying to do.
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Jan 21st, 2005, 01:09 PM
#3
Thread Starter
Junior Member
Re: Class Modules and Forms
I am trying to write a DLL and the problem that I having is that I need to get the value of a string variable from form1 of a Class Module (clGetAutomationDrives) to the Class module (clGetAutomationDrives). Can anyone tell me how to do this. This is my first exposure to Class Modules
GOAL: I have created a form that is in a Class Module project. I need to get a text string from this form to the Class Module:
Here is the code within the Class Module (form1):
VB Code:
Public Function GETDRIVES_INNTGXPFS1() As String
' THIS SUBROUTINE FINDS ALL OF THE LOGICAL DRIVES AND THEN FINDS THE
' DRIVE THAT IS NAMED AUTOMATION and is 10 characters long AND RETRIEVES THE DRIVE LETTER
Dim x, y As Integer
'Search each drive for an "Automation" indication
For x = 0 To Drive1.ListCount - 1
y = InStr(1, Drive1.List(x), "Automation", 1)
If y = 18 Then
'If found, assign the drive letter and exit the routine
GETDRIVES_INNTGXPFS1 = Mid(Drive1.List(x), 1, 1)
x = Drive1.ListCount - 1
End If
Next
'GETDRIVES_INNTGXPFS1 = MAPPEDDRIVE_INNTGXPFS1
End Function
Private Sub Form_Load()
GETDRIVES_INNTGXPFS1
End Sub
Public Property Let getdriveletter(ByVal vNewValue As String)
getdriveletter = GETDRIVES_INNTGXPFS1
End Property
Here is the code in the class module (clGetAutomationDrives):
[Highlight=VB]
Public MAPPEDDRIVE_INNTGXPFS1 As String
Public GETDRIVES_INNTGXPFS1 As String
Public Function loadform()
Form1.Visible = True
End Function
Public Property Get getdriveletter() As String
getdriveletter = GETDRIVES_INNTGXPFS1
End Property
[Highlight=VB]
Here is the code in the test form to test the DLL:
[Highlight=VB]
Option Explicit
Private Sub Command1_Click()
Dim test As New clGetAutomationDrives
' Create the objects
Set test = New clGetAutomationDrives
MsgBox test.loadform
Debug.Print "GETDRIVES_INNTGXPFS1="; getdriveletter
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
[Highlight=VB]
-
Jan 21st, 2005, 01:41 PM
#4
Re: Class Modules and Forms
1) Make a Public Property on the Form that exposes the String.
2) Make a Public Property on the Class that exposes the Form's Public Property.
VB Code:
' In the Form1
Public Property Get getdriveletter() as String
getdriveletter = "Some String."
End Property
VB Code:
' In the Class module
Public Property Get getdriveletter() as String
getdriveletter = Form1.getdriveletter()
End Property
Will that help you out?
Nobody knows what software they want until after you've delivered what they originally asked for.
Don't solve problems which don't exist.
"If I had eight hours to cut down a tree, I'd spend six hours sharpening my axe." --- Abraham Lincoln (1809-1865)
2 idiots don't make a genius.
-
Jan 21st, 2005, 03:20 PM
#5
Thread Starter
Junior Member
Re: Class Modules and Forms
 Originally Posted by Dave Sell
1) Make a Public Property on the Form that exposes the String.
2) Make a Public Property on the Class that exposes the Form's Public Property.
VB Code:
' In the Form1
Public Property Get getdriveletter() as String
getdriveletter = "Some String."
End Property
VB Code:
' In the Class module
Public Property Get getdriveletter() as String
getdriveletter = Form1.getdriveletter()
End Property
Will that help you out?
Thank you very much. I am a bit embarrassed how easy that was. Oh well, thanks again for your help !
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|