Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Changing label captions

RonaldSRonaldS Posts: 33Member
I know how to change label captions at run time with an Input Box with the user specified caption. Is it possible to use that same caption at each run without the user having to re-enter the same information?

Comments

  • GideonOmegaGideonOmega Posts: 617Member
    : I know how to change label captions at run time with an Input Box with the user specified caption. Is it possible to use that same caption at each run without the user having to re-enter the same information?
    :

    you could write the string into a .dat or .txt file, then read the file each time the program loads and change the caption.

    you will want to make sure that you check to see if the file is empty with some error handling so you don't get problems.

    [code]
    private sub form_load()
    dim strCap as string
    dim fileNum as long

    fileNum = freefile
    strCap = ""
    open app.path & "caption.dat" for input as #fileNum
    if NOT EOF(fileNum) then
    Input #fileNum, strCap
    end if
    close #fileNum
    if strCap <> "" then
    mycontrol.caption = strCap
    end if
    [/code]

    and for writing the file, put something like this after you get the string from the input box - in this case strInCaption
    [code]

    dim fileNum as long
    fileNum = freefile

    open app.path & "caption.dat" for output as #fileNum
    write #fileNum, strInCaption
    close #fileNum
    [/code]

    Hope this helps.
    [blue]
    C:Dos
    C:Dos Run
    Run Dos Run
    [/blue]

Sign In or Register to comment.