Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

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

VB錯誤訊息-引數 'Expression' 無法轉換為型別

VB錯誤訊息-引數 \'Expression\' 無法轉換為型別\'TextBox\'。

請問這是什麼意思?

出錯的程式碼:

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

a = Val(TextBox2)

b = Val(TextBox3)

c = Val(TextBox4)

d = Val(TextBox5)

m = Val(TextBox6)

f = Val(TextBox7)

g = Val(TextBox8)

h = Val(TextBox9)

i = Val(TextBox10)

t = Val(TextBox1)

請各位高手解答

Update:

a = Val(TextBox2)

這一行

4 Answers

Rating
  • 2 decades ago
    Favorite Answer

    a = Val(TextBox2.text)

    b = Val(TextBox3.text)

    c = Val(TextBox4.text)

    d = Val(TextBox5.text)

    m = Val(TextBox6.text)

    f = Val(TextBox7.text)

    g = Val(TextBox8.text)

    h = Val(TextBox9.text)

    i = Val(TextBox10.text)

    t = Val(TextBox1.text)

    TextBox是元件,不是一個值

    TextBox中的Text才表示你要的資料,取出後再轉為你要的數字吧

    Source(s): 自己
  • Money
    Lv 5
    2 decades ago

    程式你貼完整點的嗎,我倒是覺得應該是

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    這一行的問題

  • 2 decades ago

    建議改成

    a = Val(TextBox2.text)

  • 2 decades ago

    請確定錯誤訊息發生時.程式停在那一行

Still have questions? Get your answers by asking now.