VB 简单计算器
Option Explicit
Dim potflag As Integer '标识是否用小数点
Dim numcol As Integer ' 点击运算符的个数
Dim LastInput ' 指示上一次操作的内容
Dim colflag 'numcol为1时,保存运算符
Dim temp1, temp2 '分别保存运算符两端的运算数
Private Sub CmdCel_Click() '重新开始计算按钮,个计量数和标识初始化
Res = Format(0, "0.")
temp1 = 0
temp2 = 0
numcol = 0
potflag = False
LastInput = "cel" '标识此操作为"cel"
End Sub
Private Sub CmdPot_Click() '使用小数点
If LastInput <> "num" Then
Res = Format(0, "0.")
ElseIf String(1, Res) = "-" Then
Res = Format(0, "-0.")
End If
potflag = True
LastInput = "num" '标识此操作为"num"
End Sub
Private Sub Cmdsign_Click() '使用正负号
If String(1, Res) <> "-" Then '如果当前是正数添加负号
Res = "-" & Res
Else: Res = Right(Res, Len(Res) - 1) '如果当前是证号,取消负号
End If
LastInput = "num" '标识此操作为"num"
End Sub
Private Sub ComCol_Click(Index As Integer) '点击操作符,可进行连续运算
numcol = numcol + 1 '通过numcol标识点击运算符的次数
If numcol = 1 Then '当前数为操作符左侧运算数时,记录当前操作数
temp1 = Res
&
相关文档:
Option Explicit
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
Const HTCAPTION = 2
Const WM_NCLBUTTONDOWN = &HA1
Pri ......
Option Explicit
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Private Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, Optional ByVal wFlags As Long = 0&) As Long
Private Declare Function DrawMenu ......
VB编写托盘图标有两个要点,一是使用 Shell_NotifyIcon 函数显示图标;二是向系统注册 TaskbarCreated 消息,以便explorer崩溃时恢复托盘的图标。
首先需要增加一个模块文件,内容如下:
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOT ......
Dim wdapp As Word.Application
Dim wddoc As Word.Document
Dim wdtable As Word.Table
Set wdapp = CreateObject("word.application")
Set wddoc = wdapp.Documents.Add
  ......
VERSION 5.00
Begin VB.Form Form2
AutoRedraw = -1 'True
Caption = "计算界面"
ClientHeight = 4905
ClientLe ......