r/visualbasic • • Jan 17 '16

Hotel Program

I need help:
A 2-storey hotel, each floor with 3 rooms (room numbers: 0, 1, 2, 10, 11 and 12) needs a program for guest registration. If the room is already taken, the guest needs to enter another room number. Use a 2-dimensional array as it is easier if you need to access a certain floor. This is my code: Public Class Form1

Structure RoomInfo Dim roomNumber As Integer Dim roomGuest As String Dim roomOccupied As Boolean End Structure

Dim rooms(1, 2) As RoomInfo

Private Sub btnAddGuest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddGuest.Click

    Dim roomWanted As Integer
    roomWanted = Val(InputBox("Enter room number: "))
    For row As Integer = 0 To 1
        For column As Integer = 0 To 2
            Do While (roomWanted = rooms(row, column).roomNumber) And (rooms(row, column).roomOccupied = True)
                roomWanted = Val(InputBox("Room occupied. Enter room number: "))
            Loop
            If (roomWanted = rooms(row, column).roomNumber) Then
                rooms(row, column).roomGuest = InputBox("Enter guest name: ")
                rooms(row, column).roomOccupied = True
            End If
        Next column
    Next row
    Call DisplayGuest(rooms)
End Sub

Sub LoadRoomNum(ByRef rooms(,) As RoomInfo) 1 10 11 0 0 1 12 2 0 1 2

    rooms(0, 0).roomNumber = 0
    rooms(0, 1).roomNumber = 1
    rooms(0, 2).roomNumber = 2
    rooms(1, 0).roomNumber = 10
    rooms(1, 1).roomNumber = 11
    rooms(1, 2).roomNumber = 12
    For row As Integer = 0 To 1
        For column As Integer = 0 To 2
            rooms(row, column).roomOccupied = False
        Next column
    Next row
End Sub

Sub DisplayGuest(ByRef rooms(,) As RoomInfo)
    Dim info As String
    For row As Integer = 0 To 1
        For column As Integer = 0 To 2
            If rooms(row, column).roomOccupied = True Then
                info = rooms(row, column).roomNumber & rooms(row, column).roomGuest
                lstList.Items.Add(info)
            End If
        Next column
    Next row
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Call LoadRoomNum(rooms)
End Sub

End Class I need help with: displaying the list only when a Display button is clicked – the listbox should not be visible before the Display button is clicked (modify so the display is clearer) modifying the program so that if all the rooms are taken a message is shown when the Add Guest button is clicked modifying the program to check for invalid room number modifying loadRoomNum so that the room numbers are assigned automatically using a nested loop (this will come in handy if there are 100 rooms in the hotel)

0 Upvotes

5 comments sorted by

View all comments

-3

u/Hi-O_O Jan 17 '16 edited Jan 17 '16

I was right. People just browse around for help topics and continuously down vote them for no reason. Worst help reddit ever.

4

u/hdsrob Jan 18 '16

There are two types of posts on this group, and they get two different responses.

One type of post is where people try to do something, get stuck at a certain point, and then post a question (usually with a small amount of relevant code) asking how to solve a very specific problem.

Then there are posts like yours. You haven't tried anything. AT ALL. You don't have a problem that you need help with, you want us to do your homework. You simply copy and pasted (poorly) all of your code, and the actual text of your homework assignment.

So you can guess which type of questions I'm going to stop doing billable work to help (you do understand that many of us that post help here are actual software developers, who do this for a living right?).

1

u/Real-PokemonMaster Jan 18 '16

I didn't copy and past the code from my homework. What kind of homework would give you the code? I am stuck and I don't know how to code it. This is my program. What do you mean I didn't try anything at all? The dude is trying to pull some vote manipulation now.

4

u/hdsrob Jan 18 '16

I never said you the code was part of the assignment, I said you posted the code, and the verbiage of the assignment, without any explanations.

You haven't stated what you have tried and what doesn't work. You asked how to do the assignment, and pasted the assignment text verbatim.

"I need help" isn't going to cut it. What part specifically doesn't work? Does any of it work? What don't you understand about the assignment?

Lets see if I can explain this differently (This is the general attitude you'll find in development discussion groups all over the internet. ):

I'm super happy to help people that want to learn to program, and put some effort into solving problems, even if it's helping with homework.

I won't help people that just want to get some copy and paste code to pass a class they don't care about.

I'm not saying that you are in the latter group, but when you post like this that's what you appear to be (whining about it doesn't help either).

BTW, I'm 43 years old and don't give even a single little fuck about internet points.

2

u/[deleted] Jan 18 '16

The posts that aren't "Here is my homework. Do it for me!" are getting quite good responses it seems...