導航:首頁 > 匯率傭金 > vb匯率計算器

vb匯率計算器

發布時間:2021-11-12 09:53:37

Ⅰ 用VB編寫計算器

建議用控制項數組,這樣好選擇控制項。還有就是多看看書,VB這東西還是蠻有用的。

下面這個是網路出來的:
用VB編寫計算器2007-01-09 10:36一.實驗目的
用vb語言編寫一個簡易計算器
二.實驗要求
1.能夠完成浮點數的加,減,乘,除;(平方等)
2.能夠實現退格和清除功能;
3.初始值為0.0;
4.小數點不能重復輸入;
5.高位數的0不出現;
6.應用控制項數組實現。
三.控制項屬性列表
1、創建控制項組的方法
a、首先創建一個命令按鈕,調整其大小 — 寬、高為 495,名稱為Command1,aption 屬性為數字 0 。
b、然後進行「復制」和「粘貼」,當選擇「粘貼」時,出現對話框提示已有一個同名控制項,詢問是否創建控制項組,選擇「是」後,即創建了一個名為「Command」的控制項組。這時,第一個按鈕的Index屬性值默認為「0」,第二個的Index屬性值自動設為「1」,並且大小與第一個按鈕相同,只需修改其 Caption 屬性為數字「1」並將其拖至合適位置即可。此後繼續使用「粘貼」的方法建立其他控制項組中其餘按鈕,共19個按鈕,每建立一個,就將它拖到合適處,並修改相應的Caption屬性值。
c、建立其他控制項:如右圖所示
2、各控制項屬性設置如下:
控 件 控 件
控制項 名稱 Caption 控制項 名稱 Caption
窗體 Form 1 計算器 按鈕 Command 2(0) +
按鈕 Command 3 退格 按鈕 Command 2(1) -
按鈕 Command 4 . 按鈕 Command 2(2) *
按鈕 Command 5 = 按鈕 Command 2(3) /
按鈕 command 6 + 按鈕 Command 7 ±
按鈕 Command 1(0)~Command1(9) Caption 0 ~ 9
各個屬性修改後得到如圖所示的界面

四 程序如下
Dim shu1 As Single, shu2 As Single, suanfu As String
'定義兩個單精度數變數用與存放參與運算的數,一個字元型存放運算符

Private Sub Command1_Click(Index As Integer)
Text1.Text = Text1.Text & Command1(Index).Caption
'將command1的單擊事件與文本框顯示的內容連接
End Sub

Private Sub Command2_Click(Index As Integer)
shu1 = Val(Text1.Text) '將shu1隱藏起來
suanfu = Command2(Index).Caption
Text1.Text = ""
End Sub

Private Sub Command4_Click()

Text1.Text = Text1.Text + "."
If (InStr(Text1.Text, ".") = 1) Then '第一位不能為小數
Text1.Text = ""
End If
If InStr(Text1.Text, ".") < Len(Text1.Text) Then
'防止出現兩個小數點
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)

End If

End Sub

Private Sub Command5_Click() '開始加減乘除的運算
shu2 = Val(Text1.Text)
Select Case suanfu
Case "+"
Text1.Text = shu1 + shu2
Case "-"
Text1.Text = shu1 - shu2
Case "*"
Text1.Text = shu1 * shu2
Case "/"
If shu2 = 0 Then
MsgBox "分母不能為零!", 1 + 32 + 0,
"錯誤" '錯誤提示框圖下所示
Text1.Text = ""
Else
Text1.Text = shu1 / shu2
End If
End Select
End Sub

Private Sub Command3_Click() '假如輸入錯誤,可每次退後一格
If Text1.Text = "" Then
Exit Sub
End If
Text1.Text = Left(Text1.Text, Len(Text1.Text) - 1)
End Sub

Private Sub Command6_Click()
Text1.Text = "" '清除
End Sub
Private Sub Command7_Click() '平方運算
Text1.Text = Text1.Text * Text1.Text
End Sub
Private Sub Command8_Click()
If Left(Text1.Text, 1) <> "-" Then
Text1.Text = "-" & Text1.Text
Else
Text1.Text = Right(Text1.Text, Len(Text1.Text) - 1)
End If
End Sub

Ⅱ vb的匯率轉換問題

Label2.Caption & "壹"

....
代碼沒必要寫那麼長。用mid的特性,簡化代碼

Ⅲ 用vb編寫 人民幣匯率

保存下面的代碼到一個後綴名為FRM的文件中,再用VB打開即可。
============
VERSION 5.00
Begin VB.Form Form1
Caption = "人民幣轉換工具"
ClientHeight = 3195
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3195
ScaleWidth = 4680
StartUpPosition = 3 '窗口預設
Begin VB.OptionButton Option1
Caption = "轉換成歐元"
Height = 495
Index = 3
Left = 1680
TabIndex = 4
Top = 1200
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "轉換成日元"
Height = 495
Index = 2
Left = 240
TabIndex = 3
Top = 1200
Width = 1215
End
Begin VB.OptionButton Option1
Caption = $"Form2.frx":0000
Height = 495
Index = 1
Left = 1680
TabIndex = 2
Top = 720
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "轉換成美元"
Height = 495
Index = 0
Left = 240
TabIndex = 1
Top = 720
Width = 1215
End
Begin VB.TextBox Text1
Height = 375
Left = 240
TabIndex = 0
Top = 120
Width = 1455
End
Begin VB.Label Label1
Height = 375
Left = 480
TabIndex = 5
Top = 1800
Width = 3015
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Option1_Click(Index As Integer)
Dim t As Single
t = Val(Text1.Text)
Label1.Caption = FormatNumber(Choose(Index + 1, t / 7.7, t / 15.47, t / 0.081, t / 10.8), , vbTrue)

End Sub

Ⅳ VB製作計算器

'添加窗體Form1,文本框Text1,Text2,Text3,Text4,按鈕Command1,然後添加如下代碼:
PrivateSubCommand1_Click()
Text4.Text=strCalc(Text1.Text&Text2.Text&Text3.Text)
EndSub

PublicFunctionstrCalc(Tmpstr$)AsDouble
Dimsc
Setsc=CreateObject("ScriptControl")
sc.Language="VBScript"
strCalc=sc.Eval(Tmpstr)
Setsc=Nothing
EndFunction

Ⅳ vb計算器單個數的轉換計算

我有的

Ⅵ vb 製作簡易計算器

那個plfushicn的方法也可以只是不太適合初學者.

望採納!還有不會的隨時問我!

Ⅶ vb的匯率轉換

類型不匹配(錯誤 13)
當前 Visual Basic為了完成數據類型的賦值,能夠對許多數值進行轉換,而較早的版本則做不到。然而,此錯誤仍可能發生並且有幾種原因和解決方法。

現在需要搞清楚,這個賦值式是想做字元串拼接還是是數字增加。

Ⅷ VB 計算器

簡單的方法有二種:
第一種,在單擊等號計算後清空不用的加數,這樣再次點擊等號則不會重復計算。
代碼修改如下:
Private Sub Command4_Click()
st = Text1
Text1 = sa + st
sa=0
End Sub
第二種,設置一個布爾變數,用來標識是否已經計算。代碼如下:
Option Explicit
Dim sa As Integer
Dim st As Integer
Dim 未計算 As Boolean

Private Sub Command1_Click() '按數字鍵1
If Not 未計算 Then
Text1 = ""
未計算 = True
End If
If Text1 = "" Then
Text1 = "1"
Else
Text1 = Text & "1"
End If
End Sub

Private Sub Command2_Click() '數字鍵2到0同數字鍵1。建議使用控制項數組
'
End Sub

Private Sub Command3_Click() '加號
sa = Val(Text1)
Text1.Text = ""
未計算 = True
End Sub

Private Sub Command4_Click() '等號,計算
If 未計算 Then
Text1 = sa + Val(Text1)
未計算 = False
End If
End Sub

Private Sub Form_Load()
Text1 = ""
未計算 = True
End Sub

另外,建議,程序要寫注釋。

Ⅸ 用vb做一個匯率轉換器

Text3.text=val(text1.text)*val(text2.text)

Ⅹ VB編程美元兌換人民幣代碼

private sub command1_click()
dim m as single,r as single,h as single
m=val(text1.text) '美元數量
h=8.099 '匯率
r=m*h '換算
label1.caption=Format (r, "#.##") '顯示兌換的人民幣數量
end sub

閱讀全文

與vb匯率計算器相關的資料

熱點內容
華發股份威海 瀏覽:934
查詢歐洲上市集團財報 瀏覽:138
合法股票配 瀏覽:59
000960錫業股份新浪 瀏覽:465
HOU股票 瀏覽:957
中投證券買基金 瀏覽:362
豆一期貨杠桿 瀏覽:156
國泰君安傭金2016 瀏覽:752
負債杠桿率百分之百什麼意思 瀏覽:909
天天基金券商理財無法購買 瀏覽:219
河源股份股票 瀏覽:595
前海金控互聯網金融服務有限公司怎麼樣 瀏覽:911
關於民生銀行理財產品 瀏覽:556
北京融資門檻 瀏覽:229
主要的金融機構的作用 瀏覽:395
人民幣和美元的匯率變化趨勢 瀏覽:574
怎麼查看農業銀行理財的收益 瀏覽:791
中航信託是個怎樣的貸款公司 瀏覽:691
成交量黃柱指標 瀏覽:263
國債買回購交易 瀏覽:23