
Помогите сделать калькулятор на Visual Basic. Условие а+b+c и всё это разделить на два, помогите
пожалуйста срочно!!!!

Ответы на вопрос

C#:
string AStr, BStr, CStr;
Console.WriteLine("Введите A ."); AStr = Console.ReadLine();
Console.WriteLine("Введите B ."); BStr = Console.ReadLine();
Console.WriteLine("Введите C ."); CStr = Console.ReadLine();
if(!(int.TryParse(AStr, out int A) && int.TryParse(BStr, out int B) && int.TryParse(CStr, out int C)))
{
Console.WriteLine("Введите корректные значения."); Console.ReadLine();
return;
}
int Sum = (A + B + C) / 2;
Console.WriteLine($"Сумма данных элементов разделённая на 2: {Sum}.");
Console.ReadLine();



Creating a Calculator in Visual Basic
To create a calculator in Visual Basic, you can follow these steps:
1. Open Visual Studio and create a new Windows Forms Application project. 2. Design the user interface by adding buttons and a text box to display the result. 3. Double-click on each button to create an event handler for the button's click event. 4. In the event handler for each button, write code to perform the desired calculation and display the result in the text box.
Here's an example of how you can create a simple calculator that divides the sum of three numbers by two:
1. Design the User Interface: - Add three text boxes for input (a, b, and c). - Add a button for the calculation. - Add a text box to display the result.
2. Write the Code: - Double-click on the button to create the click event handler. - In the event handler, retrieve the values from the input text boxes and convert them to numbers. - Perform the calculation by adding the three numbers and dividing the sum by two. - Display the result in the output text box.
Here's an example of the code:
```vb Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click ' Retrieve the values from the input text boxes Dim a As Double = Double.Parse(txtA.Text) Dim b As Double = Double.Parse(txtB.Text) Dim c As Double = Double.Parse(txtC.Text)
' Perform the calculation Dim result As Double = (a + b + c) / 2
' Display the result in the output text box txtResult.Text = result.ToString() End Sub ```
Make sure to replace `txtA`, `txtB`, `txtC`, `btnCalculate`, and `txtResult` with the actual names of the controls in your form.
Remember to handle any potential errors, such as invalid input or division by zero, to ensure the calculator functions correctly.
I hope this helps you create a calculator in Visual Basic! Let me know if you have any further questions.


Похожие вопросы
Топ вопросов за вчера в категории Информатика
Последние заданные вопросы в категории Информатика
-
Математика
-
Литература
-
Алгебра
-
Русский язык
-
Геометрия
-
Английский язык
-
Химия
-
Физика
-
Биология
-
Другие предметы
-
История
-
Обществознание
-
Окружающий мир
-
География
-
Українська мова
-
Информатика
-
Українська література
-
Қазақ тiлi
-
Экономика
-
Музыка
-
Право
-
Беларуская мова
-
Французский язык
-
Немецкий язык
-
МХК
-
ОБЖ
-
Психология
-
Физкультура и спорт
-
Астрономия
-
Кыргыз тили
-
Оʻzbek tili