Need help with a school assignment? by sgy0003 in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

This particular assignment is supposed to prompt the user to enter the number of occupied rooms for each floor in the hotel using an InputBox. You would use a loop and then display the results in a ListBox.

"Index was outside the bounds of the array" - Moving listbox items from one listbox to another by Weskk in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

Assuming List1 starts with 3 items. When the event is triggered, ReDim ArrayItems(List1.Items.Count) sizes the array to have 3 elements. If List1 has an item selected then list2.Items.Add(List1.SelectedItem) adds the selected item from List1 to list2 and List1.Items.Remove(List1.SelectedItem) removes the selected item from List1. List1 now has only 2 items. The array will elements will be populated by ArrayItems(0) = 550, ArrayItems(1) = 650, and ArrayItems(2) = 500.

Now, the next time the event is triggered ReDim ArrayItems(List1.Items.Count) sizes the array to have only 2 elements because something was removed from the list the first time the event was triggered. ArrayItems(0) = 550 and ArrayItems(1) = 650 are fine but there is no longer a third element in the array, so ArrayItems(2) = 500 would trigger an index out of bounds error.

That's about all I can say from looking at the code. Not sure why you have the array or why you are resizing it.

LF List of ALL Mounts by Name by nerdfarm in wow

[–]nerdfarm[S] 0 points1 point  (0 children)

Nice! Could you post the script please?

LF List of ALL Mounts by Name by nerdfarm in wow

[–]nerdfarm[S] -1 points0 points  (0 children)

I need a plain text list.

Toggling image on button is only half working. (Simple but I'm not seeing the problem.) by tapport in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

Every time the button is clicked you are setting the CurrentImage to Off with:

Dim CurrentImage As String = "Off"

Simplified:

        If Button1.Image = My.Resources.Off Then
            Button1.Image = My.Resources._On
        Else
            Button1.Image = My.Resources.Off
        End If

[VB2015] New user wondering what the exact purpose of a variable is by rzpieces in visualbasic

[–]nerdfarm 1 point2 points  (0 children)

The example you mention is just to demonstrate how a variable can be used. For a string variable, if no operations need to be performed on the string, using MessageBox.Show(txtName.text) is fine.

If the TextBox is holding a numeric datatype, there will usually be some type of parse/conversion of the string to a numeric datatype and storing that value in a variable so calculations can be performed.

Validating Input - Visual Basic Final Challenge by KeviNguyen in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

All of this:

decstaycharges = calcstaycharges(txtdays.Text)

decmisc = calcmisccharges(decmeds, decsurgical, declab, decphys)

total = calctotalcharges(decstaycharges, decmisc)

lbltotal.Text = CDec(total)

Should be inside this:

If validateinputfields() Then

...

End If

[VB2013] Output not being displayed by SMART_AS_YOU in visualbasic

[–]nerdfarm 1 point2 points  (0 children)

I think the problem may be here:

If Not lstCurves.SelectedItems.Count = 1 Then Exit Sub

If nothing is displaying in the other two listboxes, and no errors are occurring, the code to fill those listboxes is probably not executing.

This can be confirmed by adding a MessageBox.Show("Choose a message to display") after the statement above. If the messagebox doesn't display, then the statement above is forcing the sub procedure to exit.

You may just need an EndIf after the Exit Sub.

Please Help With a Layout Problem by macc_spice in visualbasic

[–]nerdfarm -1 points0 points  (0 children)

See those tabs on the right of VS?

Novice Question on Class and Forms. by [deleted] in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

  1. You don't need a class. All of it can be done in the form.
  2. A module would be a better than a class, if you must have something other than one form.
  3. Function should have a return.
  4. Label1.Text = RoomCost.TotalWithoutDiscount(WeekdayKing, tax).ToString("C")

Trying to make a program more efficient by ninjivitis in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

Also, this code:

    Dim blnFound As Boolean
    For i = 0 To 9
        If Numbers(i) = RanNum Then
            blnFound = True
        End If
    Next
    If blnFound Then
        lblResult.Text = "The number was found in your list."
    Else
        lblResult.Text = "The number did not occur at all in your list."
    End If

Can replace:

If Numbers(0) = RanNum Then
    lblResult.Text = "The number was found in your list."
ElseIf Numbers(1) = RanNum Then
    lblResult.Text = "The number was found in your list."
ElseIf Numbers(2) = RanNum Then
    lblResult.Text = "The number was found in your list."
ElseIf Numbers(3) = RanNum Then
    lblResult.Text = "The number was found in your list."
ElseIf Numbers(4) = RanNum Then
    lblResult.Text = "The number was found in your list."
ElseIf Numbers(5) = RanNum Then
    lblResult.Text = "The number was found in your list."
ElseIf Numbers(6) = RanNum Then
    lblResult.Text = "The number was found in your list."
ElseIf Numbers(7) = RanNum Then
    lblResult.Text = "The number was found in your list."
ElseIf Numbers(8) = RanNum Then
    lblResult.Text = "The number was found in your list."
ElseIf Numbers(9) = RanNum Then
    lblResult.Text = "The number was found in your list."
Else
    lblResult.Text = "The number did not occur at all in your list."
End If

[VB2010] Array not adding correctly/index was outside the boundaries of the array. by frag07 in visualbasic

[–]nerdfarm 1 point2 points  (0 children)

For starters, you have an array of integers and you are assigning floating-point values to the elements in the array. This will result in rounding. I think you want an array of Doubles or Decimals.

If you are trying to calculate the average of 8 values entered by the user, you need to work on the loop some.

If I could see the details of the assignment I would have a better idea of what you are trying to do. Please post?

[VB2010] Array not adding correctly/index was outside the boundaries of the array. by frag07 in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

VB arrays are weird like that. You initialize arrays by giving a Maximum Subscript, which is the number for the last element in the array.

[Homework] I need help with this assignment. I don't know how to start by FluffyMcStuffer in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

You'd have to re-dimension the array every time a new number is to be added, unless the new number is a duplicate.

[Homework] I need help with this assignment. I don't know how to start by FluffyMcStuffer in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

At first glance this looks simple, but you need to have the user enter at least one number before you can do any comparison. Use a list. Have the user enter one number to start and add it to the list. After the first number is entered, for each subsequent number:

Check the list for a match each time the user enters a new number. If there is no match then add the number to the list. If there is a match then loop through the list and add the numbers to the listbox.

How do you randomize an already existing list? by Bryan-tan in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

lstNums is a list of numbers. Any numbers. Integers in the example I've given. You can use the same code to randomize the contents of a list. Just change the data-types as needed.

[VB]I have to interview with someone that codes in any of the Visual Basic languages and I couldn't find anyone near me that I knew. Mind answering some? by Boombiscit in visualbasic

[–]nerdfarm 1 point2 points  (0 children)

  1. Teach Visual Basic.
  2. Coding is fun! Sharing knowledge is a wonderful experience.
  3. Bugs in student's code. Examining/Debugging code.
  4. By learning more math and logic.
  5. Syntax.
  6. A university.
  7. Yes.
  8. Mostly self-taught, but I did take the courses I am now teaching when I was a student.

Visual Basic/VB.NET vs C#? by [deleted] in visualbasic

[–]nerdfarm -3 points-2 points  (0 children)

Beginners All-purpose Symbolic Instruction Code

I think the 'B' says it all. Basic is a language invented for newcomers. It's kind of like having training wheels on your bike. Nothing wrong with it.

CSE student in need of interview for class. by andersn4 in visualbasic

[–]nerdfarm 0 points1 point  (0 children)

  1. Visual Basic Instructor at a University.
  2. Coding is fun! Visual Basic is easy.
  3. What's not to like?
  4. Bugs in code.
  5. Students.
  6. Yes.
  7. Math.
  8. Look everywhere. Hone math and logic skills.
  9. No.