21. december 2010 - 19:48Der er
10 kommentarer og 1 løsning
lommeregner
hej jeg er i gang med at programmere en lommeregner til et skoleprojekt og jeg har faktisk lavet en lommeregner, MEEN selve "." (komma) funktionen fungere simpelthen ikke og jeg ved ikke hvordan jeg skal få det til at virke. er der en som kan hjælpe ?
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click TextBox1.Text = TextBox1.Text & "." End Sub
når jeg fx skriver: 5,5+4,5 så siger den at svaret er 9 . og når jeg har tastet "." og derefter taster et nyt tal, laver den sig selv om til et "," (komma i stedet for punktum)
Sub showvalue(ByVal butt As Button) Form1.TextBox1.Text = Val(Form1.TextBox1.Text & butt.Text) End Sub
Sub arithematic(ByVal butt As Button) Form1.Value1 = Val(Form1.TextBox1.Text) Form1.Oper = butt.Text Form1.TextBox1.Text = "" End Sub
Sub calculate() Select Case Form1.Oper Case "+" Form1.TextBox1.Text = Form1.Value1 + Val(Form1.TextBox1.Text) Case "-" Form1.TextBox1.Text = Form1.Value1 - Val(Form1.TextBox1.Text) Case "*" Form1.TextBox1.Text = Form1.Value1 * Val(Form1.TextBox1.Text) Case "/" Form1.TextBox1.Text = Form1.Value1 / Val(Form1.TextBox1.Text) End Select End Sub Public Class Form1 Public Value1 As Double Public value2 As Double Public Oper As Char
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click showvalue(Button7) End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click showvalue(Button8) End Sub
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click showvalue(Button9) End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click showvalue(Button4) End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click showvalue(Button5) End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click showvalue(Button6) End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click showvalue(Button1) End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click showvalue(Button2) End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click showvalue(Button3) End Sub
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click showvalue(Button10) End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click arithematic(Button13) End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click arithematic(Button14) End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click arithematic(Button15) End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click arithematic(Button11) End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click Value2 = Val(TextBox1.Text) calculate() showhistory() value2 = 0 SayIt() End Sub
Private Sub ToolStripDropDownButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripDropDownButton1.Click Me.Width = 328 ToolStripDropDownButton1.Text = "Historie Fra" End Sub
Private Sub HistorieTilToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HistorieTilToolStripMenuItem.Click Me.Width = 579 ToolStripDropDownButton1.Text = "Historie Til" End Sub
Private Sub Button24_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button24.Click TextBox1.Text = Math.Sqrt(Val(TextBox1.Text)) End Sub Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click TextBox1.Text = "0" Value1 = 0 value2 = 0 Oper = "" End Sub Private Sub Button22_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button22.Click TextBox1.Text = Val(TextBox1.Text) \ 10 End Sub Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click TextBox1.Text = (22 / 7) End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click TextBox1.Text = Val(TextBox1.Text * TextBox1.Text) End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click TextBox1.Text = TextBox1.Text & "." End Sub
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.