Results 1 to 2 of 2

Thread: [02/03] Randomizing and save/load system

  1. #1

    Thread Starter
    Member Shadow45o's Avatar
    Join Date
    Sep 2008
    Posts
    51

    [02/03] Randomizing and save/load system

    Ok, first off, I'm fairly new to visual basic or visual studio, I can pick up code pretty easily though. I know I wrote a lot, but I was trying to give enough details...So thanks in advance for any help given.

    My questions are:

    How would I make a button that would randomize which picture shows up on a picture box or on a button so that it wouldn't always be the same. For example, with a game of memory that has a basic title screen with a "start button. Once that button is pressed, I would want it to randomize the pictures so that they wouldn't be in the same place all the time when "start" was pressed.

    Secondly, I would like to know of a way to make it so that once a button was pressed, it would save a text or ".txt" file in a folder on a computer without actually showing the dialog box asking to save. This would be for a partial login system. So for instance, I pressed register and a new window comes up, I fill in that and press submit and it would save the text file with the user and password. Then I would want a load system that would locate that file once the user and pass are typed in, and if it finds it, then it will allow entry to the program.

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: [02/03] Randomizing and save/load system

    For question 1: put your pictures in a collection (an array, a list...) and generate a random integer from 0 to the collection's count. Once you have that random number, use it as the index to get the picture from the list and assign that to your picturebox.

    For question 2: Use System.IO.File.ReadAllText(filepath) to read a text file and use System.IO.File.WriteAllText(filepath, text) to write the text to a text file.
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

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