29. december 2005 - 17:37Der er
6 kommentarer og 2 løsninger
Hjælp til regneprogram
Hej Eksperter.
Jeg er nybegynder til VB, og kan derfor kun det grundlæggende. Jeg er ligenu igang med at prøve at lave et regneprogram, her er koden jeg har fået bikset sammen foreløbigt.
Private Sub Form_Load() Text1.Text = "" Label1.Caption = "" Text2.Text = "" Command1.Caption = "+" Command2.Caption = "-" Command3.Caption = "*" Command4.Caption = "/" Command5.Caption = "Udregn!" Label2.Caption = "Facit:" End Sub Private Sub Command1_Click() Label1.Caption = "+" End Sub Private Sub Command2_Click() Label1.Caption = "-" End Sub Private Sub Command3_Click() Label1.Caption = "*" End Sub Private Sub Command4_Click() Label1.Caption = "/" End Sub Private Sub Command5_Click() If Label1.Caption = "+" Then intA = Text1.Text intB = Text2.Text intStykke = intA + intB Label2.Caption = "Facit: " End If If Label1.Caption = "-" Then Label2.Caption = "Facit: " End If If Label1.Caption = "*" Then Label2.Caption = "Facit: " End If If Label1.Caption = "/" Then Label2.Caption = "Facit: " End If End Sub ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Der mangler lidt med udregningen, nogen der kan hjælpe mig lidt til at få programmet færdigt?
Private Sub Form_Load() Text1.Text = "" Label1.Caption = "" Text2.Text = "" Command1.Caption = "+" Command2.Caption = "-" Command3.Caption = "*" Command4.Caption = "/" Command5.Caption = "Udregn!" Label2.Caption = "Facit:" End Sub Private Sub Command1_Click() Label1.Caption = "+" End Sub Private Sub Command2_Click() Label1.Caption = "-" End Sub Private Sub Command3_Click() Label1.Caption = "*" End Sub Private Sub Command4_Click() Label1.Caption = "/" End Sub Private Sub Command5_Click()
Select Case Label1.Caption Case "+" Label2.Caption = "Facit: " & Val(Text1.Text) + Val(Text2.Text) Case "-" Label2.Caption = "Facit: " & Val(Text1.Text) - Val(Text2.Text) Case "*" Label2.Caption = "Facit: " & Val(Text1.Text) * Val(Text2.Text) Case "/" Label2.Caption = "Facit: " & Val(Text1.Text) / Val(Text2.Text) Case Else MsgBox "fejl" End Select End Sub
A = InputBox("Intast vinkel (A) i grader") A = A / 180 * 3.14159265358979 B = InputBox("Intast længde (B) i mm") X = B * Tan(A) MsgBox "resultet er " & X
End Sub
Private Sub Command11_Click() Dim A As Double Dim B As Double Dim X As Double
B = InputBox("Intast vinkel (B) i grader") B = B / 180 * 3.14159265358979 A = InputBox("Intast længde (A) i mm") X = A / Cos(B) MsgBox "resultet er " & X
End Sub
Private Sub Command12_Click() Dim A As Double Dim B As Double Dim X As Double
A = InputBox("Intast længde (A) i mm") B = InputBox("Intast længde (B) i mm") X = (Sqr(B ^ 2 + A ^ 2)) MsgBox "resultet er " & X
End Sub
Private Sub Command2_Click() Dim A As Double Dim B As Double Dim X As Double
A = InputBox("Intast vinkel i grader") A = A / 180 * 3.14159265358979 B = InputBox("Intast længde i mm") X = A / B MsgBox "resultet er " & X End Sub
Private Sub Command3_Click() Dim A As Double Dim B As Double Dim X As Double
B = InputBox("Intast vinkel (B) i grader") B = B / 180 * 3.14159265358979 A = InputBox("Intast længde (A) i mm") X = A / Sin(B) MsgBox "resultet er " & X End Sub
Private Sub Command5_Click() Dim A As Double Dim B As Double Dim X As Double
A = InputBox("Intast vinkel (A) i grader") A = A / 180 * 3.14 B = InputBox("Intast længde (B) i mm") X = B * Tan(A) MsgBox "resultet er " & X
End Sub
Private Sub Command6_Click() Dim A As Double Dim B As Double Dim X As Double
A = InputBox("Intast længde (A) i mm") B = InputBox("Intast længde (B) i mm") C = Sqr((A * A) + (B * B)) / 180 * 3.14159265358979 X = A / Sin(C) MsgBox "resultet er " & X
End Sub
Private Sub Command7_Click() Dim A As Double Dim B As Double Dim X As Double
A = InputBox("Intast vinkel (A) i grader") A = A / 180 * 3.14159265358979 B = InputBox("Intast længde (B) i mm") X = B * Cos(A) MsgBox "resultet er " & X
Takker mange gange.. smid et svar begge to i får 100 point hver, havde godt nok kun brug for det første men har også lært noget af dit sidste trekant script hansen.. takker mange gange.. :)
Lige en ting til, kan i ikke lige vise hvordan man tilføjer en værdi til en værdi..
fek.s jeg har en Tekstbox der står 1 i, og jeg har 10 knapper med tallene 0 til 9 hvor man kan trykke på dem og så tilføjer den tallet bagved, så hvis jeg trykker 5 så står der 15 i boksen og derefter 3 så står der 153?
Hej jannick281090 jeg siger mange tak Hvis det er iorden med kabbak da det var ham der hjalp dig med dit spørsmål jeg ville bare vise en anden måde man kunde stille en udregning op på
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.