Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

?
Lv 6

Visual basic 2010 question (20 characters)?

So I am making this form in visual basic 2010 but I have a problem. I filled in my code for the button like I would normally do but for some reason I need to click two times before I can see my results (code below). Also, how can I make the ComboBox have a default item?

Const pepperoni As Integer = 10

Const bbqkip As Integer = 12

Const hamkaas As Integer = 15

Const vegetarisch As Integer = 18

Const ansjovis As Integer = 2

Const garnalen As Integer = 3

Const mozerellakorst As Integer = 4

Const spek As Integer = 3

Dim prijs As Integer

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click

TextBox1.Text = prijs

If RadioButton1.Checked = True Then

prijs = pepperoni

If CheckBox1.Checked = True Then

prijs += ansjovis

End If

If CheckBox2.Checked = True Then

prijs += garnalen

End If

If CheckBox3.Checked = True Then

prijs += mozerellakorst

End If

If CheckBox4.Checked = True Then

prijs += spek

End If

If ComboBox1.SelectedItem = "Personal" Then

prijs = prijs

Else

If ComboBox1.SelectedItem = "Small" Then

prijs = prijs * 1.2

Else

If ComboBox1.SelectedItem = "Medium" Then

prijs = prijs * 1.5

Else

If ComboBox1.SelectedItem = "Large" Then

prijs = prijs * 1.7

Else

If ComboBox1.SelectedItem = "DE ULTIEME PIZZA" Then

prijs = prijs * 2

End If

End If

End If

End If

End If

End If

(this code for all four radiobuttons and the combobox was created in the design window)

3 Answers

Relevance
  • 9 years ago
    Favorite Answer

    To use your code, simply move the following line to the bottom of the code

    TextBox1.Text = prijs

    You now have it directly under the "Private Sub Button....

    You place a price in the textbox before the value has been determined, therefore you have to click the button again in order for the price to be placed in the textbox.

    TexMav

  • Anonymous
    9 years ago

    Public Class Form1

    Public Const pepperoni As Integer = 10

    Public Const bbqkip As Integer = 12

    Public Const hamkaas As Integer = 15

    Public Const vegetarisch As Integer = 18

    Public Const ansjovis As Integer = 2

    Public Const garnalen As Integer = 3

    Public Const mozerellakorst As Integer = 4

    Public Const spek As Integer = 3

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    TextBox1.Text = ""

    If RadioButton1.Checked = True Then

    TextBox1.Text = pepperoni

    If CheckBox1.Checked = True Then

    TextBox1.Text += ansjovis

    ElseIf CheckBox2.Checked = True Then

    TextBox1.Text += garnalen

    ElseIf CheckBox3.Checked = True Then

    TextBox1.Text += mozerellakorst

    ElseIf CheckBox4.Checked = True Then

    TextBox1.Text += spek

    End If

    End If

    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

    If ComboBox1.SelectedItem = "Personal" Then

    TextBox1.Text = TextBox1.Text

    ElseIf ComboBox1.SelectedItem = "Small" Then

    TextBox1.Text = TextBox1.Text * 1.2

    ElseIf ComboBox1.SelectedItem = "Medium" Then

    TextBox1.Text = TextBox1.Text * 1.5

    ElseIf ComboBox1.SelectedItem = "Large" Then

    TextBox1.Text = TextBox1.Text * 1.7

    ElseIf ComboBox1.SelectedItem = "DE ULTIEME PIZZA" Then

    TextBox1.Text = TextBox1.Text * 2

    End If

    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    ComboBox1.Items.Add("Personal")

    ComboBox1.Items.Add("Small")

    ComboBox1.Items.Add("Medium")

    ComboBox1.Items.Add("Large")

    ComboBox1.Items.Add("DE ULTIEME PIZZA")

    End Sub

    End Class

    This some code. U can use it... Ready to go.. Cheers

  • ?
    Lv 4
    5 years ago

    Forget the compliments of peers. They are best to get however more commonly they've little or no inspiration of honestly how well, or dangerous, your paintings is. I might recommend becoming a member of a regional artwork society as a begin. I wager you're rather younger so you are going to discover many of the participants of an artwork society will look to be extremely ancient. However, if you'll get on with them you'll be in a position to get recommendation, each on learn how to promote your paintings and in addition approaches to upgrade it. Most artwork societies have a minimum of one exhibition a yr in which participants show their paintings on the market. Another means is to pay to become a member of a internet site that allows for you to exhibit and promote your paintings. This will rate you at least 40GBP and probably plenty extra. Another likelihood is at a vehicle boot sale. Or you would experiment the water by means of asking if you'll have a desk within the college corridor (if you're nonetheless at college) and feature your paintings on the market with all of the cash to visit a charity. If you're well at images I might get 3 or 4 performed, mount them smartly and cleanly in a bit portfolio so you'll exhibit them to loved ones and peers and allow them to realize you might be completely happy to attract them however that you just might like a small fee in your time and ability. If this works you would discover neighbours or even strangers fitting interested. If this works out you particularly CAN'T be a lazy artist. You ought to take it critically and provide the items. Good Luck!

Still have questions? Get your answers by asking now.