harryv
asked on
Value from another form
In my first form (start.frm) there is a value FindStr. Can I use this value in anthoter form warning.frm?
In start.frm there is set a value FindStr.
If something is found, it opens warning.frm
How to show the value FindStr from start.frm in warning.frm?
Jeffeny
In start.frm there is set a value FindStr.
If something is found, it opens warning.frm
How to show the value FindStr from start.frm in warning.frm?
Jeffeny
If you create a Property in warning.frm and then warning.frm.FindStr=start. frm.FindSt r may give you a quck solution.
ASKER
Hoi,
It gives an error on Start.frm.FindStr
Private Sub Form_Load()
Dim FindStr As String
Warning.frm.FindStr = Start.frm.FindStr
MsgBox "WARNING: " & FindStr, vbCritical
End Sub
What's wrong?
It gives an error on Start.frm.FindStr
Private Sub Form_Load()
Dim FindStr As String
Warning.frm.FindStr = Start.frm.FindStr
MsgBox "WARNING: " & FindStr, vbCritical
End Sub
What's wrong?
Add a bas module and define FindStr as public:
' in a bas module
Public FindStr as string
' in a bas module
Public FindStr as string
If start is the name of the form
Use Start.FindStr
Use Start.FindStr
Yes you can but you have to declare this value as property, like this: Public FindStr As String
Now it can be accessed from any form like: Start.FindStr and you can use this as any other variable.
P.S. You dont have to write a form extension becouse it can make people confused. Just saying that this is a form should be enough.
Now it can be accessed from any form like: Start.FindStr and you can use this as any other variable.
P.S. You dont have to write a form extension becouse it can make people confused. Just saying that this is a form should be enough.
Yes,but if you put "Public FindStr as string" in a bas module,then you can use FindStr on any form without specifying a form name in front.
If you are using VB 6 you need to define the Property
dim mFindStr as String
Public Property Get FindStr () as string
FindStr =mFindStr
end Property
Public Property Let FindStr (newVal as string)
mFindStr=newVal
end Property
dim mFindStr as String
Public Property Get FindStr () as string
FindStr =mFindStr
end Property
Public Property Let FindStr (newVal as string)
mFindStr=newVal
end Property
These Properties need to be defined in the Form
ASKER
Ok I have created a module1 (module1.bas) with the text
Public FindStr As String
But:
Private Sub Form_Load()
MsgBox "WARNING: " & Start.FindStr, vbCritical
End Sub
Gives an error on Findstr
Do I have to include the module?
?
Public FindStr As String
But:
Private Sub Form_Load()
MsgBox "WARNING: " & Start.FindStr, vbCritical
End Sub
Gives an error on Findstr
Do I have to include the module?
?
remove start
If you put it in a module,then just use this on your form:
Private Sub Form_Load()
MsgBox "WARNING: " & FindStr, vbCritical
End Sub
Private Sub Form_Load()
MsgBox "WARNING: " & FindStr, vbCritical
End Sub
directly reference Findstr
ASKER
No value
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes!!!