/* (程序头部注释开始)
* 程序的版权和版本声明部分
* Copyright (c) 2011, 烟台大学计算机学院学生
* All rights reserved.
* 文件名称: 《计算器的设计——VB》
* 作 者: 刘江波
* 完成日期: 2013 年 3 月 14 日
* 版 本 号: v2.3
* 对任务及求解方法的描述部分
* 问题描述:
* 程序头部的注释结束
*/
界面展示:
代码:
Imports System.Math Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Height = 190 End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Me.Height = 360 End Sub Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click Dim c As Char c = Trim(ComboBox1.Text) Select Case c Case "+" TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text) Case "-" TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text) Case "*" TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text) Case "/" TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text) End Select End Sub Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click TextBox5.Text = Sin(Val(TextBox4.Text)) End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click TextBox5.Text = Sqrt(Val(TextBox4.Text)) End Sub Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click TextBox5.Text = Oct(Val(TextBox4.Text)) End Sub Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click TextBox5.Text = Cos(Val(TextBox4.Text)) End Sub Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click TextBox5.Text = Log(Val(TextBox4.Text)) End Sub Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click TextBox5.Text = Hex(Val(TextBox4.Text)) End Sub Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.LostFocus End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged If Not IsNumeric(TextBox1.Text) Then TextBox1.Text = "" TextBox1.Focus() End If End Sub Private Sub TextBox2_BorderStyleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.BorderStyleChanged End Sub Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress End Sub Private Sub TextBox2_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox2.LostFocus End Sub Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged If Not IsNumeric(TextBox2.Text) Then TextBox2.Text = "" TextBox2.Focus() End If End Sub Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox4.TextChanged If Not IsNumeric(TextBox4.Text) Then TextBox4.Text = "" TextBox4.Focus() End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub End Class