[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!
Re: Insert Select Case into Text File
You cannot pass instructions dynamically.
Re: Insert Select Case into Text File
Sounds like you want to create an Add-In.
Re: Insert Select Case into Text File
Quote:
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.
Re: Insert Select Case into Text File
Quote:
Originally Posted by
MarMan
Sounds like you want to create an Add-In.
I guess you can call it that...
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.
Re: Insert Select Case into Text File
Quote:
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
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
Re: Insert Select Case into Text File
Quote:
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!
Re: Insert Select Case into Text File
Quote:
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? :confused: :rolleyes: