Monday, 15 June 2015

vb.net - Is this program efficient -


I have a small calculator application that works quite well, but despite being a newbie to VB.net Know that the program is probably not as efficient as it should be. The idea is that after inputting numbers into a text box and pressing the mathematical operator, the text will reset the box and the equation will continue, as the previous values ​​are entered. Double-numeric functions in the form of slow dimfunction as dull input 1 (zeros = 0, = 1 to add, subtract = 2, partition = 3, multiplication = 4);

  Deputy btnAdd_Click (as the object, handles btnAdd.Click e RoutedEventArgs) txtNum.Text = "" then MsgBox ( "a number") or Numfunction 1 = input 1 = input 1 + txtNum.Text txtNum. Text = "" end end sub Private sub btnEqual_Click (as this object, e manages as RoutedEventArgs) recorded btnEqual.Click so txtNum.Text = "" then MsgBox ( "Enter a last number of N ") then numfunction = 1 then txtNum.Text = txtNum.Text + input 1 input 1 = 0 ending End Sub  

You could talk to me in adding my program or What should I do to remove this is the right direction in the future MS is more efficient? Keep in mind that BtnAdd_Click event just a (add, sub, division, multiplication) of 4 and a statement because it will btnEqual_Click, then you have effectively put in the work users, and anything there txtNum If checked for all at all.

Thank you in advance, I am not asking anyone to complete my code, but I have to see in the future that what I like to do in creating more efficient programs in the future.

With a little initial effort, you can simplify this task by using the power of object-oriented programming. :

Formerly Public category form 1 'lists a list of operations in the list of operations for the new operation (operation of) as a personal operation Operation currently operating the operation of private property As the operation number '2 you want to perform operations May include private _number1 double as = 0 Personal _number2 double as = 0 Public Sub New () Prarnbhiksmuh ()) Setapopreshn () text boxes 1. Text = 0 End Sub Public Sub Priwartnopreshn (acting as operations) _number1 = _currentOperation.FunctionDelegate.Invoke (_number1, _number2) TextBox1.Text = _number1 _currentOperation = Operation End Sub Private Sub Setapopreshn () _operations.Add (new operation (m , BTNED, Function (X, Y) Returns X + Y and Function)) 'Works of Chorus ... you use an anonymous method to define your work so that they are form (m) and related buttons' All for once 'other tasks The new operation (m, btnqual, function (x, y) returns and end function) as the same (decrease / multiply / split / pow, and so on) dim equivalent operation. Add operation for this example (equal operation) _currentOperation = equalsOperation End Sub 'I have only a text box and a Yogyaniy indicated a legitimate double private all text box number entered is 1_TextChanged (sender as object, and EventArgs as) handles TextBox1.TextChanged Dim res Ult as double then double.TryParse (TextBox1.Text, result) then _number2 = result lblValid.Text = 'valid' 'user entered that number, it is valid or does not tell or else lblValid.Text = "invalid" means the last if end Sub '' '& lt; Summary & gt; '' 'An operation operation that hooks a button' '' & lt; / Summary & gt; Specify public class operations as private privatization form 1 as public property function Use a representative for funnel (double, double, double) funnel which gives double returns with two double parameters Public sub new (Proprietary form form 1, button in the form of a bound button, double as function, double, double)) Me.FunctionDelegate = functionDelegate Me._owningForm = owningForm AddHandler boundButton.Click, AddressOf boundButton_Click's' End Sub Private Sub boundButton_Click () _owningForm.ChangeOperation (Me) End Sub Click making operation hook event

I hope this is not too confusing for you, I compare the simple routine and Gtnahston I want to show a big world in


No comments:

Post a Comment