VB Mail order
I am trying to code this problem but kinda having a problem. here is what i have so far. Need some pointers if anyone can help. Also here is the problem.
'some way of creating prgram in a sup script. Match the weght and weight limit. It is worth while to
'Create a project that will calculate shipping charges from a two-dimensional table of rates. The rate depends on the weight
of the pakage and the zone to which 'it will be shipped. The weight column specfies the max weight for the rate. All weights over 10 pounds use the last row.
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim weight(,) As Decimal = {{1.0, 1.5, 1.65, 1.85}, {1.58, 2.0, 2.4, 3.05}, {1.71, 2.52, 3.1, 4.0}, {2.04, 3.12, 4.0, 5.01}, {2.52, 3.75, 5.1, 7.25}}
Dim num1, num2 As Integer
Dim results As Decimal
For num1 = TextBox1.Text = 0 To 19
For num2 = TextBox2.Text = 0 To 3
If num1 < 3 Then
weight(1, num2) = True
ElseIf num1 < 5 Then
weight(2, num2) = True
ElseIf num1 < 10 Then
weight(3, num2) = True
ElseIf num1 >= 10 Then
weight(4, num2) = True
End If
Next
Next
Label4.Text = results
End Sub
End Class```
pigmanbear wrote: I am trying to code this problem but kinda having a problem. here is what i have so far. Need some pointers if anyone can help. Also here is the problem.
'some way of creating prgram in a sup script. Match the weght and weight limit. It is worth while to
'Create a project that will calculate shipping charges from a two-dimensional table of rates. The rate depends on the weight
of the pakage and the zone to which 'it will be shipped. The weight column specfies the max weight for the rate. All weights over 10 pounds use the last row.
You have got the information. What do you want? What do you need help with? Do you want us to post a solution?
pigmanbear wrote: Well i am stuck. All my output comes out to 0. It seems as if the information is not being gathered from the array. Not exactly sure. I am not trying to get an solution but some pointer or some feedback to help me out.
markupLabel4.Text = results
If the output is in the label then it isn't that strange since you only defined the variable results without assigning ANY VALUE TO IT IN THE WHOLE CODE.
I don't know VB so I kinda can't help you much.
So do you think i should assign num1 and num2 to something, and then that something will be assign to results?
Another question about the array. Can i assign a specific number to each row of line from the array. Because i do not want the user input to be starting from 0. So can i assign it so it will start at 1?
pigmanbear wrote: So do you think i should assign num1 and num2 to something, and then that something will be assign to results?
You should assign what your output has to be to the results before outputting it to the label or else the results will stay 0 for ever. Like in your code, the results does not get changed and then you try to assign nothing to a label which by default assumes that nothing is 0 and outputs 0.
Another question about the array. Can i assign a specific number to each row of line from the array. Because i do not want the user input to be starting from 0. So can i assign it so it will start at 1?
I don't think so. If you would be able to assign number 1 to row 0 and number 5 to row 1 it would get chaotic and slow down your compilation time or even program speed. I don't know if you can set a starting point at which it starts to count in VB, it varies from programming language to programming language if you can do that.
You should assign what your output has to be to the results before outputting it to the label or else the results will stay 0 for ever. Like in your code, the results does not get changed and then you try to assign nothing to a label which by default assumes that nothing is 0 and outputs 0.
So kinda having a little problem with this. So i need to output num1 and num2 to results right?
How it is set up, is it gathering information from the array?
Mtutnid wrote: Programming isn't for you. You have no logical thinking. Give up or stop wasting your time here and go and learn how to THINK.
Why would i give up when i am trying to learn. That is not how i work. I keep trying. If your not gonna help me then don't reply please, but if you do reply and help me out. That would be greatly appreciated
Public Class Form1
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim weight(,) As Decimal = {{1.0, 1.5, 1.65, 1.85}, {1.58, 2.0, 2.4, 3.05}, {1.71, 2.52, 3.1, 4.0}, {2.04, 3.12, 4.0, 5.01}, {2.52, 3.75, 5.1, 7.25}}
Dim num1, num2 As Integer
Dim results As Decimal
For num1 = TextBox1.Text = 0 To 19
For num2 = TextBox2.Text = 0 To 3
If num1 < 3 Then
weight(1, num2) = True
ElseIf num1 < 5 Then
weight(2, num2) = True
ElseIf num1 < 10 Then
weight(3, num2) = True
ElseIf num1 >= 10 Then
weight(4, num2) = True
Weight(num1, num2) = results
Label4.Text = results
End If
Next
Next
End Sub
End Class.
I added the output to the results, but now it gives me an over flow.
Well I know shit about VB, but perhaps this helps:
- VB is case sensitive right? Why does "Weight(num1, num2) = results" start with a capital W?
- That line of code is strange anyway. You assign the value of the variable 'results' to some fixed array element? Shouldn't it be the other way around?
- Because 'results' is still empty then.
- num1 can contain values from 0 to 19. But your weight array contains only 5 elements. I guess this is why you get an IndexOutOfRangeException…
- In this nested for loop, you keep on changing Label4.Text, which is visible in some GUI I assume. Is this necessary? Because the user will probably only see the last one anyway.
Oh, and use the code-tags as you did on your previous post.
Good luck with this…
The problem with your script is that you're not understanding the concept of assignment in programming.
- Read this until you understand it: http://msdn.microsoft.com/en-us/library/cd6hcy37%28VS.80%29.aspx
- Read your code. Read it again.
- You're trying to set the label text to show the variable called results, so set results equal to something instead of setting weight() equal to true or some other nonsense.
- You don't need "For" loops. You're using them to assign num1 and num2, but you can assign them without it.
- Re-read 3 and 4 until you get the meaning of each, then fix them.
You don't need someone to create a "snippet" for you. You need to learn, and you need to be taught. So, get to work.
define wrote: The problem with your script is that you're not understanding the concept of assignment in programming.
- Read this until you understand it: http://msdn.microsoft.com/en-us/library/cd6hcy37%28VS.80%29.aspx
- Read your code. Read it again.
- You're trying to set the label text to show the variable called results, so set results equal to something instead of setting weight() equal to true or some other nonsense.
- You don't need "For" loops. You're using them to assign num1 and num2, but you can assign them without it.
- Re-read 3 and 4 until you get the meaning of each, then fix them.
You don't need someone to create a "snippet" for you. You need to learn, and you need to be taught. So, get to work.
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim weight(,) As Decimal = {{1.0, 1.5, 1.65, 1.85}, {1.58, 2.0, 2.4, 3.05}, {1.71, 2.52, 3.1, 4.0}, {2.04, 3.12, 4.0, 5.01}, {2.52, 3.75, 5.1, 7.25}}
Dim num1, num2 As Integer
Dim results As Decimal
For num1 = TextBox1.Text
For num2 = TextBox2.Text
If num1 < 3 Then
weight(1, num2) = True
ElseIf num1 < 5 Then
weight(2, num2) = True
ElseIf num1 < 10 Then
weight(3, num2) = True
ElseIf num1 >= 10 Then
weight(4, num2) = True
results = weight(num1, num2)
Label4.Text = results
End If
End Sub
End Class```
I assigned results to weight and the array, but now i don't get any output. I am not sure if my code is even coded right. What am i doing wrong?