Anonymous
Anonymous asked in 電腦與網際網路程式設計 · 2 decades ago

宣告 Dim 的問題

假設我要將所有的"收入"作加總

Dim a

Adodc1.Recordset.MoveFirst

While Not Adodc1.Recordset.EOF

If Adodc1.Recordset.Fields(0) = "收入" Then

a = a + Adodc1.Recordset.Fields(0)

Else

a = a + 0

End If

Adodc1.Recordset.MoveNext

Wend

Text1 = a

這樣Text 就會顯示 a 加總後數字

可是如果我想讓Text顯示 XXX元

Text1 = a + "元"

又會錯誤,請問該怎麼辦?

(以前都是用 Text1 = Text2 + "元" 而現在正是用宣告a來代替Text2)

3 Answers

Rating
  • 上官
    Lv 5
    2 decades ago
    Favorite Answer

    在最後一行text1=a之後再加上

    text1=text1 + "元"

    就行了吧

    Source(s): 上機測試
  • Anonymous
    2 decades ago

    Text1 = a & "元"

    Text1 = CStr(a) + "元"

    Text1 = CStr(a) & "元"

    都可以

  • Lv 7
    2 decades ago

    用text1 = "" + a + "元"試試

    2005-06-19 12:40:56 補充:

    不好意思,我錯了.應是無聊的人才對.用 &

Still have questions? Get your answers by asking now.