-
Mar 18th, 2011, 06:30 AM
#1
Thread Starter
Junior Member
[RESOLVED] Insert Select Case into Text File
Hi,
I know how to use the select case command, however if I want to make a really long case, it would take me forever to write Case 0, Case 1, Case 2, etc. for each thing.
So I was wondering if there was a way that I could just put a list of names in a text file, and simply modify the text file so that after every name, Case x will be printed (x grows +1 each time).
Thanks!
-
Mar 18th, 2011, 07:23 AM
#2
Re: Insert Select Case into Text File
You cannot pass instructions dynamically.
-
Mar 18th, 2011, 07:31 AM
#3
Re: Insert Select Case into Text File
Sounds like you want to create an Add-In.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Mar 18th, 2011, 07:41 AM
#4
Thread Starter
Junior Member
Re: Insert Select Case into Text File
Originally Posted by RhinoBull
You cannot pass instructions dynamically.
I'm not trying to get someone to make it for me, I'm just giving an example.
-
Mar 18th, 2011, 07:41 AM
#5
Thread Starter
Junior Member
Re: Insert Select Case into Text File
Originally Posted by MarMan
Sounds like you want to create an Add-In.
I guess you can call it that...
-
Mar 18th, 2011, 07:44 AM
#6
Re: Insert Select Case into Text File
Depending on your situation, there are several potential alternatives that would be far simpler.
If you give us an example of the Select Case that you want to create, we can make apt suggestions.
-
Mar 18th, 2011, 07:48 AM
#7
Thread Starter
Junior Member
Re: Insert Select Case into Text File
Originally Posted by si_the_geek
Depending on your situation, there are several potential alternatives that would be far simpler.
If you give us an example of the Select Case that you want to create, we can make apt suggestions.
Code:
Randomize
m = int(rnd*501)
Select Case m
Case 0
label1.caption="Word1"
Case 1
label1.caption="Word2"
And Etc.
Each word comes from 1 line of a .txt file in app.path
-
Mar 18th, 2011, 07:57 AM
#8
Re: Insert Select Case into Text File
In that case load the file into an array, and simply read from the array.
The entire code for this would then become:
Code:
Randomize
m = int(rnd*501)
label1.caption = YourArray(m)
(note that Randomize should only be called once for your entire program, so move that line to somewhere like Form_Load)
For an explanation of arrays, see the article in the "Data types/variables" section of our Classic VB FAQs (in the FAQ forum)
If you don't know how to load from a text file, see the "Files" section of the FAQs
-
Mar 18th, 2011, 08:01 AM
#9
Thread Starter
Junior Member
Re: Insert Select Case into Text File
Originally Posted by si_the_geek
In that case load the file into an array, and simply read from the array.
The entire code for this would then become:
Code:
Randomize
m = int(rnd*501)
label1.caption = YourArray(m)
(note that Randomize should only be called once for your entire program, so move that line to somewhere like Form_Load)
For an explanation of arrays, see the article in the "Data types/variables" section of our Classic VB FAQs (in the FAQ forum)
If you don't know how to load from a text file, see the "Files" section of the FAQs
Thanks!
I am familiar with arrays, having used them before, but the File commands helped.
Thanks again!
-
Mar 18th, 2011, 08:10 AM
#10
Re: Insert Select Case into Text File
Originally Posted by bowiz2
I'm not trying to get someone to make it for me, I'm just giving an example.
What's this got to do with what I said in post #2?
Tags for this Thread
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
|