Members Online
Total Online: 31 Web Spiders: 17
Guests Online: 30
Members Online: 1
Registered Members: 70218 Newest Member: iceiceice
|
View Thread
| Author |
VB Mail order |
pigmanbear
Member
Posts: 64
Location:
Joined: 25.03.08 Rank: Active User |
|
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 scblockedript. 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.
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
End If
Next
Next
Label4.Text = results
End Sub
End Class
|
|
| Author |
RE: VB Mail order |
Mtutnid
Member
Posts: 79
Location: HELL
Joined: 22.09.10 Rank: Hacker Level 3 |
|
|
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 scblockedript. 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? |
|
| Author |
RE: VB Mail order |
pigmanbear
Member
Posts: 64
Location:
Joined: 25.03.08 Rank: Active User |
|
|
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. |
|
| Author |
RE: VB Mail order |
Mtutnid
Member
Posts: 79
Location: HELL
Joined: 22.09.10 Rank: Hacker Level 3 |
|
|
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.
Label4.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.
Edited by Mtutnid on 18-10-10 16:31 |
|
| Author |
RE: VB Mail order |
pigmanbear
Member
Posts: 64
Location:
Joined: 25.03.08 Rank: Active User |
|
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? |
|
| Author |
RE: VB Mail order |
Mtutnid
Member
Posts: 79
Location: HELL
Joined: 22.09.10 Rank: Hacker Level 3 |
|
|
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. |
|
| Author |
RE: VB Mail order |
pigmanbear
Member
Posts: 64
Location:
Joined: 25.03.08 Rank: Active User |
|
|
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? |
|
| Author |
RE: VB Mail order |
Mtutnid
Member
Posts: 79
Location: HELL
Joined: 22.09.10 Rank: Hacker Level 3 |
|
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.
So remember when you're feeling very small and insecure
How amazingly unlikely is your birth
And pray that there's intelligent life somewhere up in space
'Cause there's bugger all down here on Earth
Edited by Mtutnid on 19-10-10 12:56 |
|
| Author |
RE: VB Mail order |
pigmanbear
Member
Posts: 64
Location:
Joined: 25.03.08 Rank: Active User |
|
|
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.
http://i18.photobucket.com/albums/b106/grabit5000/omg.jpg |
|
| Author |
RE: VB Mail order |
GTADarkDude
Member

Posts: 142
Location: The Netherlands
Joined: 23.02.08 Rank: God |
|
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...
... |
|
| Author |
RE: VB Mail order |
pigmanbear
Member
Posts: 64
Location:
Joined: 25.03.08 Rank: Active User |
|
|
Well I guess i am really lost. If someone could code a snippet on how exactly it should look that would be great. It seems as if i got the wrong concept of this. |
|
| Author |
RE: VB Mail order |
define
Member
Posts: 201
Location:
Joined: 13.12.08 Rank: Moderate Warn Level: 1
|
|
The problem with your scblockedript is that you're not understanding the concept of assignment in programming.
1. Read this until you understand it: http://msdn.microsoft.com/en-us/library/cd6hcy37%28VS.80%29.aspx
2. Read your code. Read it again.
3. 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.
4. You don't need "For" loops. You're using them to assign num1 and num2, but you can assign them without it.
5. 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.
If you need to contact me, send me a PM. I will read and/or respond in time. |
|
| Author |
RE: VB Mail order |
pigmanbear
Member
Posts: 64
Location:
Joined: 25.03.08 Rank: Active User |
|
|
define wrote:
The problem with your scblockedript is that you're not understanding the concept of assignment in programming.
1. Read this until you understand it: http://msdn.microsoft.com/en-us/library/cd6hcy37%28VS.80%29.aspx
2. Read your code. Read it again.
3. 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.
4. You don't need "For" loops. You're using them to assign num1 and num2, but you can assign them without it.
5. 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.
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
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? |
|
| Author |
RE: VB Mail order |
AldarHawk
The Manager

Posts: 1663
Location: Canada
Joined: 26.01.06 Rank: God |
|
pigmanbear, all I can do is shake my head.
READ YOUR CODE!
You will then notice your error. If you do not, programming is not your line of work. Read some books if you do not understand this issue. I will give you a hint...it is in your results!
|
|
|
|
|