Results 1 to 10 of 10

Thread: [RESOLVED] Insert Select Case into Text File

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    22

    Resolved [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!

  2. #2

  3. #3
    Frenzied Member
    Join Date
    Jan 2010
    Location
    Connecticut
    Posts
    1,687

    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

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    22

    Re: Insert Select Case into Text File

    Quote Originally Posted by RhinoBull View Post
    You cannot pass instructions dynamically.
    I'm not trying to get someone to make it for me, I'm just giving an example.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    22

    Re: Insert Select Case into Text File

    Quote Originally Posted by MarMan View Post
    Sounds like you want to create an Add-In.
    I guess you can call it that...

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,927

    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.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    22

    Re: Insert Select Case into Text File

    Quote Originally Posted by si_the_geek View Post
    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

  8. #8
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,927

    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

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Posts
    22

    Re: Insert Select Case into Text File

    Quote Originally Posted by si_the_geek View Post
    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!

  10. #10

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
  •  



Click Here to Expand Forum to Full Width