VB 2008 Programming

posted by .

HELP!!!!
I'm not sure How to get started nor the steps to design this project.

The file MEMBERS.TXT contains the names of the 100 members of a club. Write a program to randomly select people to serve as President, Treasurer, and Secretary. Note: A person cannot hold more than one office.

  • VB 2008 Programming -

    Read the list of names into an array of strings.
    Randomly choose a number between 1 and 100. If the array-element="EMPTY", choose again. Otherwise the post (president, treasurer or secretary)and the associated name, THEN reset the name to "EMPTY".
    Post your code and data if you need more help.
    If the n

  • VB 2008 Programming -

    This is my code :



    Public Class frmOffice

    Private Sub btnDisplay_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisplay.Click
    Dim randomNum As New Random
    Dim name1, name2, name3 As String
    Dim sr As IO.StreamReader = IO.File.OpenText("MEMBERS.TXT")
    name1 = CStr(sr.ReadLine)
    name1 = CStr(txtMembers.Text)
    name2 = CStr(sr.ReadLine)
    name2 = CStr(txtMembers.Text)
    name3 = CStr(sr.ReadLine)
    name3 = CStr(txtMembers.Text)
    txtMembers.Text = (" " &_ name1 & " " & name2_
    & " " & name3)
    End Sub
    End Class

  • VB 2008 Programming -

    I've revised my code and am including it now. I've tried to debug it, but am stuck on trying to get it to run properly.


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOffice.Click
    'Randomlly select office members
    Dim randomNum As New Random
    Dim sr As IO.StreamReader = IO.File.OpenText("MEMBERS.TXT")
    If randomNum.Next(0, 100) = 0 Then
    txtMembers.Text = "President"
    txtName.Text = CStr(CInt(txtName.Text + 1))
    ElseIf randomNum.Next(1, 100) = 0 Then
    txtMembers.Text = "Treasurer"
    txtName.Text = CStr(CInt(txtName.Text + 1))
    ElseIf randomNum.Next(2, 100) = 0 Then
    txtMembers.Text = "Secretary"
    txtName.Text = CStr(CInt(txtName.Text + 1))
    End If
    txtName.Text = President & " " & Treasurer & " " & Secretary " "
    End Sub
    End Class

  • VB 2008 Programming -

    Also I'm a little confused with your suggestion. Could you restate it a little differentlly for me? Thanks.

  • VB 2008 Programming -

    1. the source file does not compile because in the print statement, the titles President, ... have not been enclosed in double quotes to make a string. The compiler thinks that it is a variable name, and cannot resolve it.
    There is also an extra double quote at the end.

    2. The major problem is you have declared the IO.reader, but have not done anything to read the file. So the array would be still empty.

    3. The third one is a little detail that has to be included, namely, once you have "elected" a member, you have to eliminate him/her from other posts. This can be done by printing the title and the name, and THEN changing the name to "EMPTY" or other sentinel of your choice. When you pick a name, you have to pick again if the name happens to be "EMPTY".

    Give it a try and post your new code.

    You're along the right track.

  • VB 2008 Programming -

    create a project that stores personal information for a electronic black book the fields in the file should include name phone number pager number cell number voice mail

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. algebra

    Sharing cost. The members of a flying club plan to share equally the cost of a $200,000 airplane. The members want to find five more people to join the club so that the cost per person will decrease by $2000. How many members are currently …
  2. algebra repost

    Sharing cost. The members of a flying club plan to share equally the cost of a $200,000 airplane. The members want to find five more people to join the club so that the cost per person will decrease by $2000. How many members are currently …
  3. algebra

    Sharing cost. The members of a flying club plan to share equally the cost of a $200,000 airplane. The members want to find five more people to join the club so that the cost per person will decrease by $2000. How many members are currently …
  4. math

    mrs loya sponsers the spanish club at central middle school.the club has 8 members who are sixth graders,12 members who are sventh graders, 10 members who are eight graders. what percent of the spanish club members are seventh graders(what …
  5. Unix Script

    "Using "if" statement checks for a file called "student.txt" in the current directory. Removes (deletes) the file if it exist. This file will collect last name, first name, and grade for 5 people. Use a while loop to get the information …
  6. Unix Shell script

    Shell script Using "if" statement checks for a file called "student.txt" in the current directory. Removes (deletes) the file if it exist. This file will collect last name, first name, and grade for 5 people. Use a while loop to get …
  7. Computer Science

    I need to write a program to solve for the following: Suppose that the file USPRES.txt contains the names fo the frist 43 United States presidents and the file USSENATE.TXT contains the names of all former and present US Senators. …
  8. programming

    You are required to design and write an application that will analyze an input file (InputFile.txt); the file contains a date on each line. Your algorithm should output all the missing dates, excluding Saturdays and Sundays. You should …
  9. computer programming

    Boardman College maintains two files—one for Sociology majors and another for Anthropology majors. Each file contains students' ID numbers, last names, first names, and grade point averages. Each file is in student ID number order. …
  10. PreCalculas

    1.Suppose you pay $16,000 for a new car and estimate that it will be worth 20% less with each passing year. What will your car be worth after 3 years?

More Similar Questions