|
-
Jun 28th, 2005, 09:17 PM
#1
Thread Starter
Addicted Member
[Resolved] String As Variable
Lets say I have a string that contains label.Caption. The variable name is Send (Not the useage but similar structure)
I want to know how would I get it to show frmHello.Show instead of Send on Runtime.
I want it to show
label.Caption = Value
instead of
Send = Value
It seems so simple! Do I need to declare an object. If so How. I'm still learning the object useage. The book isn't being very nice w/ me right now.
Last edited by DJHotIce; Jun 28th, 2005 at 10:15 PM.
-
Jun 28th, 2005, 09:18 PM
#2
Re: String As Variable
i dont understand your question at all..please clarify a bit
-
Jun 28th, 2005, 09:24 PM
#3
Thread Starter
Addicted Member
Re: String As Variable
I want to dynamically create an event that will insert information inside of a control.
So I need to define a var and a value. I'm using a module to do this, I plan on reusing this event.
I have a dialog that shows up and it calculates a value, I want that value to be inserted correctly when I hit the update button. So far I've got the field to be updated to the dialog. Now I need to output it out.
-
Jun 28th, 2005, 09:25 PM
#4
Re: String As Variable
If 'Send' is a Variable as you stated, then:
label1.Caption = Send should work!
However, I suspect that a few keys pieces of info are missing 
Bruce.
-
Jun 28th, 2005, 09:28 PM
#5
Re: String As Variable
Is it that the Variable 'Send' has limited scope?
Is it Public, declared at the Module level so it can be seen by a Form?
Bruce.
-
Jun 28th, 2005, 09:29 PM
#6
Thread Starter
Addicted Member
Re: String As Variable
Bruce! I see what your saying. That would work only for a few problems! But that would be cool. I might consider it if all else fails. Possibly put a prefix on all items that could be updated. but that would mean I would have to take all my code back to the drawing board for validation techniques.
Lets say for instance I want to send something to a textbox like ImaTextbox. I couldn't use that example
I want
Var1 = Var2
Var 1 references an control to be updated and Var2 shows the value of the control
-
Jun 28th, 2005, 09:30 PM
#7
Thread Starter
Addicted Member
Re: String As Variable
Bruce, This is my Brainstorming Code:
VB Code:
Public Function PassBack(ByVal Send As String, ByVal Value As String) As Long
[Send] = Value
End Function
-
Jun 28th, 2005, 09:32 PM
#8
Re: String As Variable
Var 1 references an control to be updated and Var2 shows the value of the control
text1.text = label1.caption?
-
Jun 28th, 2005, 09:37 PM
#9
Re: String As Variable
Ok,
i [think] I understand.
If you know the name of the contol (Label in this case), you can append a number to it like:
VB Code:
Me.Controls("Label" & 1).Caption = "Test"
Bruce.
-
Jun 28th, 2005, 09:37 PM
#10
Re: String As Variable
Alternatly, you could pass the Control ByReference as an argument in that sub.
-
Jun 28th, 2005, 09:40 PM
#11
Thread Starter
Addicted Member
Re: String As Variable
Ok Thanks Bruce, I'm very satisfied w/ your responses. Added to your reputation, and am closing this by calling it resolved.
-
Jun 28th, 2005, 09:41 PM
#12
Re: [Resolved] String As Variable
Ok,
Try:
VB Code:
Option Explicit
Private Sub Form_Load()
Call PassBack(ImaTextbox, "This is a Test")
End Sub
Public Sub PassBack(ByRef Send As TextBox, ByVal strValue As String)
Send = strValue
End Sub
I changed the Function to a Sub (as noting (in this case) was being passed back)
-
Jun 28th, 2005, 09:46 PM
#13
Re: [Resolved] String As Variable
The appending a number is not the solution here (I dont beleive) - that was just an example if you did know just the name of the control. I think the solution is to pass the
control (see Sub in previous post).
Bruce.
-
Jun 28th, 2005, 09:47 PM
#14
Thread Starter
Addicted Member
Re: [Resolved] String As Variable
Read My mind, I was looking for some code to help me. I wasn't fully sure what you wanted, but before I posted ran a quick google and nothing showed up! Thanks again!
-
Jun 28th, 2005, 09:58 PM
#15
Thread Starter
Addicted Member
Re: String As Variable
I'm getting a type mismatch error. And It's pointing to
VB Code:
Private Sub Submit_Click()
Call TextBack(Label3[b].Caption[/b], txtMil.Text)
End Sub
Hmmmm. THe Textbox is a MaskedEdit box, I've changed that in the Sub.
VB Code:
Public Sub TextBack(ByRef Send As MaskEdBox, ByVal strValue As String)
Send = strValue
End Sub
Edit, However a normal textbox DOES work.
What is up with Masked edit. Oh Well I'll work on it.
Last edited by DJHotIce; Jun 28th, 2005 at 10:12 PM.
-
Jun 28th, 2005, 10:34 PM
#16
Thread Starter
Addicted Member
Re: [Resolved] String As Variable
I'm pulling the text from a var label.caption but it won't work.
This is because it is not a valid textbox item. However the text contained within that is the key. How do I break the variable and show only the text. I keep getting this text mismatch error. And have it narrowed it down to that issue.
-
Jun 28th, 2005, 10:58 PM
#17
Re: [Resolved] String As Variable
Post your code. I don't understand what the label has to do with the textbox.
-
Jun 28th, 2005, 11:30 PM
#18
Re: [Resolved] String As Variable
Does 'Label3.Caption' identify a Control? ie Text1?
-
Jun 28th, 2005, 11:41 PM
#19
Re: [Resolved] String As Variable
If so, then I succsefully tested this:
VB Code:
Option Explicit
Private Sub Submit_Click()
Call TextBack([b](Me.Controls(Label1.Caption)[/b], txtMil.Text)
End Sub
Public Sub TextBack(ByRef Send As TextBox, ByVal strValue As String)
Send = strValue
End Sub
In this case, my Labe1's Caption = "Text1".
Note: I used a TextBox.... (cant load MaskedEditBox on this PC)
Bruce.
-
Jun 29th, 2005, 09:49 AM
#20
Thread Starter
Addicted Member
Re: [Resolved] String As Variable
Ahha, little modifying of the code and it works. Thanks again!
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
|