|
-
Dec 22nd, 2006, 09:29 AM
#1
Thread Starter
New Member
[RESOLVED] How do I get VB to read the...
What I'm trying to do is to get VB to read the actual value stored inside the variable instead of just reading its', name here's what I mean.
VB Code:
Dim strString as String
strString = "SubName"
Call strString 'so you see I want VB to call SubName instead of strString
-
Dec 22nd, 2006, 09:38 AM
#2
Re: How do I get VB to read the...
Have two command buttons....
VB Code:
Private Sub Command1_Click()
Dim Subname As String
Subname = "SubA"
CallSubroutine Subname
End Sub
Private Sub Command2_Click()
Dim Subname As String
Subname = "SubB"
CallSubroutine Subname
End Sub
Private Sub CallSubroutine(ByVal sub_name As String)
CallByName Me, sub_name, VbMethod
End Sub
Public Sub SubA()
MsgBox "This is SubA"
End Sub
Public Sub SubB()
MsgBox "This is SubB"
End Sub
-
Dec 22nd, 2006, 09:38 AM
#3
Re: How do I get VB to read the...
The value stored in strString is "SubName" as you set it...
If you want to execute a function then just do
-
Dec 22nd, 2006, 09:43 AM
#4
Thread Starter
New Member
Re: How do I get VB to read the...
oh thanks a lot that help so much but how would I do the same thing with images?
-
Dec 22nd, 2006, 09:44 AM
#5
Re: How do I get VB to read the...
Can you explain further what you want to do with 'images'
-
Dec 22nd, 2006, 09:50 AM
#6
Thread Starter
New Member
Re: How do I get VB to read the...
i mean
dim strName as string
strName = "Car"
imgImage = strName
-
Dec 22nd, 2006, 09:57 AM
#7
Re: How do I get VB to read the...
No I don't think thats possible, unless you insert thousands of images into your project and give each a reference name
-
Dec 22nd, 2006, 10:13 AM
#8
Re: How do I get VB to read the...
I think this should work, though I did not test it:
VB Code:
Option Explicit
Private Pictures As New Collection
Private Sub Form_Load()
Dim strName As String
Pictures.Add LoadPicture("C:\Car.jpg"), "Car"
Pictures.Add LoadPicture("C:\House.jpg"), "House"
Pictures.Add LoadPicture("C:\Toy.jpg"), "Toy"
Pictures.Add LoadPicture("C:\UFO.jpg"), "UFO"
' ..... etc...
strName = "UFO"
imgImage.Picture = Pictures(strName)
End Sub
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
|