VB Dim a As ...的作業問題 急!

請問各位大大

Public Class Form1

Dim A As String = txtShow

Dim B As String = txtShow2

Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

lblFinal.Text = "謝謝您訂購" & A & B

End Sub

End Class

請問一下 怎麼將上面那些變成 "謝謝您訂購" & A & B

這段呢?

txtShow& txtShow2 都是文字方塊

打算將輸入完的字串

在點下btnSend的時

可以一起顯示出來

EX" 謝謝您訂購Asa(A是廠牌)N601筆記型電腦(B是產品名稱)

類似以上的做法 請各位大大能教我嘛?謝謝大家

P.S 目前小弟用的是 VB2008 Express版!

1 Answer

Rating
  • 1 decade ago
    Best Answer

    首先…若是txtShow& txtShow2皆為Textbox,那麼~

    Dim A As String = txtShow

    Dim B As String = txtShow2

    這兩行應該改成:

    Dim A As String = txtShow.Text

    Dim B As String = txtShow2.Text

    因為您要的是這兩個文字方塊的"值"嘛。

    所以啦!只要把原來的程式加上你本來就寫好的東西:

    ---

    Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

    Dim A As String = txtShow.Text

    Dim B As String = txtShow2.Text

    lblFinal.Text = "謝謝您訂購" & A & B

    End Sub

    End Class

    ---

    就可以囉!或是直接寫成:

    ---

    Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click

    lblFinal.Text = "謝謝您訂購" & txtShow.Text & txtShow2.Text

    End Sub

    End Class

    ---

    Source(s): 自已簡單的看法…
Still have questions? Get your answers by asking now.