-
Jul 29th, 2021, 06:38 PM
#41
Thread Starter
Member
Re: Need help with listbox texts to have a value and add onto another textbox
Originally Posted by .paul.
Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Threading.Thread.CurrentThread.CurrentCulture = New CultureInfo("en-GB")
End Sub
Error - Type 'CultureInfo" is not defined.
-
Jul 29th, 2021, 06:50 PM
#42
Re: Need help with listbox texts to have a value and add onto another textbox
Code:
Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-GB")
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 29th, 2021, 07:03 PM
#43
Thread Starter
Member
Re: Need help with listbox texts to have a value and add onto another textbox
Originally Posted by .paul.
Code:
Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-GB")
awesome that made into pounds, the two other questions that remain are as follows. There's a checkbox that when selected itll add 50 pounds to the total which it did but then the pound symbol disappears and the second question is that, theres a textbox2 that calculates a discount basically if the total value is over 200 pounds itll deduce 10% from the total and put it on the textbox3 which is labeled as New total
Code:
If CheckBox1.Checked = True Then
TextBox1.Text = total.ToString("c2") + 50
-
Jul 29th, 2021, 07:17 PM
#44
Re: Need help with listbox texts to have a value and add onto another textbox
Where do you put the original total code?
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 29th, 2021, 07:22 PM
#45
Re: Need help with listbox texts to have a value and add onto another textbox
The reason I ask is that between the end of the loops and setting textbox1.text you can use an if statement where you add 50 to total if your checkbox is checked. Then after setting textbox.text, use another if statement for your case where total >= 200 to calculate and display a discounted price in textbox3 in the same way I showed you with textbox1
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 29th, 2021, 07:25 PM
#46
Thread Starter
Member
Re: Need help with listbox texts to have a value and add onto another textbox
Originally Posted by .paul.
The reason I ask is that between the end of the loops and setting textbox1.text you can use an if statement where you add 50 to total if your checkbox is checked. Then after setting textbox.text, use another if statement for your case where total >= 200 to calculate and display a discounted price in textbox3 in the same way I showed you with textbox1
Code:
Private Sub purbtn_Click(sender As Object, e As EventArgs) Handles purbtn.Click
Dim prices1(0) As Integer
Dim prices2(4) As Integer
prices1(0) = 10
prices2(0) = 11
prices2(1) = 15
prices2(2) = 20
prices2(3) = 50
prices2(4) = 90
Dim allPrices(1)() As Integer
allPrices(0) = prices1
allPrices(1) = prices2
Dim listBoxes() As ListBox = {ListBox1, ListBox2}
Dim total As Integer = 0
For x As Integer = 0 To listBoxes.GetUpperBound(0)
For y As Integer = 0 To listBoxes(x).Items.Count - 1
If listBoxes(x).SelectedIndices.Contains(y) Then
total += allPrices(x)(y)
End If
Next
Next
TextBox1.Text = total.ToString("c2")
If CheckBox1.Checked = True Then
TextBox1.Text = total.ToString("c2") + 50
End If
If TextBox1.Text = total.ToString("c2") Then
TextBox3.Text = total.ToString("c2")
End If
If TextBox1.Text = total.ToString("c2") + 50 Then
TextBox3.Text = total.ToString("c2") + 50
End If
-
Jul 29th, 2021, 07:45 PM
#47
Re: Need help with listbox texts to have a value and add onto another textbox
Code:
If CheckBox1.Checked = True Then
total += 50
End If
TextBox1.Text = total.ToString("c2")
If total >= 200 then
Dim discountedTotal As Decimal = CDec(total * 0.9)
TextBox3.Text = discountedTotal.ToString("c2")
End If
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 29th, 2021, 07:48 PM
#48
Re: Need help with listbox texts to have a value and add onto another textbox
Your new homework is to figure out where to put that last code, and tell me why it works…
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 29th, 2021, 08:34 PM
#49
Thread Starter
Member
Re: Need help with listbox texts to have a value and add onto another textbox
Originally Posted by .paul.
Code:
If CheckBox1.Checked = True Then
total += 50
End If
TextBox1.Text = total.ToString("c2")
If total >= 200 then
Dim discountedTotal As Decimal = CDec(total * 0.9)
TextBox3.Text = discountedTotal.ToString("c2")
End If
youre an angel sent from above
Code:
Private Sub purbtn_Click(sender As Object, e As EventArgs) Handles purbtn.Click
'declaring that the prices are numbers and that there is 5 of them
Dim prices1(0) As Integer
Dim prices2(4) As Integer
prices1(0) = 10
prices2(0) = 11
prices2(1) = 15
prices2(2) = 20
prices2(3) = 50
prices2(4) = 90
Dim allPrices(1)() As Integer
allPrices(0) = prices1
allPrices(1) = prices2
Dim listBoxes() As ListBox = {ListBox1, ListBox2}
Dim total As Integer = 0
'making sure they all add up properly in a specified text box based on which one was highlighted
For x As Integer = 0 To listBoxes.GetUpperBound(0)
For y As Integer = 0 To listBoxes(x).Items.Count - 1
If listBoxes(x).SelectedIndices.Contains(y) Then
total += allPrices(x)(y)
End If
Next
Next
'declaring that ticking that will add 50 pounds to the total
If CheckBox1.Checked = True Then
total += 50
End If
TextBox1.Text = total.ToString("c2")
If total >= 200 Then
Dim discountedTotal As Decimal = CDec(total * 0.9)
TextBox3.Text = discountedTotal.ToString("c2")
End If
i did it but when i uncheck it, it doesnt go away and the value of the discount is not shown in the textbox2.text
-
Jul 29th, 2021, 08:53 PM
#50
Re: Need help with listbox texts to have a value and add onto another textbox
Code:
Private Sub calculateTotals
'declaring that the prices are numbers and that there is 5 of them
Dim prices1(0) As Integer
Dim prices2(4) As Integer
prices1(0) = 10
prices2(0) = 11
prices2(1) = 15
prices2(2) = 20
prices2(3) = 50
prices2(4) = 90
Dim allPrices(1)() As Integer
allPrices(0) = prices1
allPrices(1) = prices2
Dim listBoxes() As ListBox = {ListBox1, ListBox2}
Dim total As Integer = 0
'making sure they all add up properly in a specified text box based on which one was highlighted
For x As Integer = 0 To listBoxes.GetUpperBound(0)
For y As Integer = 0 To listBoxes(x).Items.Count - 1
If listBoxes(x).SelectedIndices.Contains(y) Then
total += allPrices(x)(y)
End If
Next
Next
'declaring that ticking that will add 50 pounds to the total
If CheckBox1.Checked = True Then
total += 50
End If
TextBox1.Text = total.ToString("c2")
If total >= 200 Then
Dim discountedTotal As Decimal = CDec(total * 0.9)
TextBox3.Text = discountedTotal.ToString("c2")
End If
End Sub
Code:
Private Sub purbtn_Click(sender As Object, e As EventArgs) Handles purbtn.Click
CalculateTotals
End Sub
Code:
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
CalculateTotals
End Sub
Honestly, you’d better know why this homework does what it does, because if your teacher asks you to explain it…
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 29th, 2021, 09:26 PM
#51
Thread Starter
Member
Re: Need help with listbox texts to have a value and add onto another textbox
Originally Posted by .paul.
Code:
Private Sub calculateTotals
'declaring that the prices are numbers and that there is 5 of them
Dim prices1(0) As Integer
Dim prices2(4) As Integer
prices1(0) = 10
prices2(0) = 11
prices2(1) = 15
prices2(2) = 20
prices2(3) = 50
prices2(4) = 90
Dim allPrices(1)() As Integer
allPrices(0) = prices1
allPrices(1) = prices2
Dim listBoxes() As ListBox = {ListBox1, ListBox2}
Dim total As Integer = 0
'making sure they all add up properly in a specified text box based on which one was highlighted
For x As Integer = 0 To listBoxes.GetUpperBound(0)
For y As Integer = 0 To listBoxes(x).Items.Count - 1
If listBoxes(x).SelectedIndices.Contains(y) Then
total += allPrices(x)(y)
End If
Next
Next
'declaring that ticking that will add 50 pounds to the total
If CheckBox1.Checked = True Then
total += 50
End If
TextBox1.Text = total.ToString("c2")
If total >= 200 Then
Dim discountedTotal As Decimal = CDec(total * 0.9)
TextBox3.Text = discountedTotal.ToString("c2")
End If
End Sub
Code:
Private Sub purbtn_Click(sender As Object, e As EventArgs) Handles purbtn.Click
CalculateTotals
End Sub
Code:
Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
CalculateTotals
End Sub
Honestly, you’d better know why this homework does what it does, because if your teacher asks you to explain it…
I understand that but now values are not showing in textbox3.text until the value of textbox1.text is over 200, the discounts in textbox2.text is not being shown either and when the checkbox1.checked = false, the amount is not substracted back from the new total in textbox3.text
-
Jul 29th, 2021, 09:41 PM
#52
Re: Need help with listbox texts to have a value and add onto another textbox
You told me…
textbox1 is the sum from the listBoxes
TextBox3 is the discounted total
and Textbox2 you haven’t previously mentioned
Anyway. Everything I told you will work. I’m logging off now it’s 03:40 and I have to sleep…
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jul 29th, 2021, 09:43 PM
#53
Thread Starter
Member
Re: Need help with listbox texts to have a value and add onto another textbox
Originally Posted by .paul.
You told me…
textbox1 is the sum from the listBoxes
TextBox3 is the discounted total
and Textbox2 you haven’t previously mentioned
Anyway. Everything I told you will work. I’m logging off now it’s 03:40 and I have to sleep…
i don't know how to thank you enough! thanks for for everything
-
Jul 29th, 2021, 10:42 PM
#54
Thread Starter
Member
Re: Need help with listbox texts to have a value and add onto another textbox
Originally Posted by .paul.
You told me…
textbox1 is the sum from the listBoxes
TextBox3 is the discounted total
and Textbox2 you haven’t previously mentioned
Anyway. Everything I told you will work. I’m logging off now it’s 03:40 and I have to sleep…
I will literally pray for you, thank you so much you guys! i solved it and wish i could show you <33333 thank you thank you thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|