Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net AppendText不是System.Windows.Forms.Buttons的成员_Vb.net - Fatal编程技术网

Vb.net AppendText不是System.Windows.Forms.Buttons的成员

Vb.net AppendText不是System.Windows.Forms.Buttons的成员,vb.net,Vb.net,我在txtrept.Appendtext中接收到错误。在您的代码中txtrept.Appendtext是错误的 将txtrept设置为StringBuilder 例如: Private Sub txtreciptappend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtrecipt.Click txtrecipt.Text = "" txtrecipt.appendte

我在txtrept.Appendtext中接收到错误。

在您的代码中
txtrept.Appendtext
是错误的

将txtrept设置为
StringBuilder

例如:

Private Sub txtreciptappend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtrecipt.Click

    txtrecipt.Text = ""
    txtrecipt.appendtext("" + vbNewLine)
    txtrecipt.Appendtext("===========================Online Activation Pay Slip=========================" + vbNewLine)
    txtrecipt.Appendtext("==============================================================================" + vbNewLine)
    txtrecipt.Appendtext("" + vbNewLine)

    txtrecipt.Appendtext("" + vbNewLine)
    txtrecipt.Appendtext("Employee Name: " + vbTab & NameTextBox.Text + vbTab + vbTab + vbTab & EmployerTextBox.Text + vbNewLine)
    txtrecipt.Appendtext("Address: " + vbTab & AddressTextBox.Text + vbNewLine)
    txtrecipt.Appendtext("ID: " + vbTab & IDTextBox.Text + vbNewLine)
    txtrecipt.Appendtext(vbTab + vbTab + vbTab + vbTab + vbTab + vbTab & "PRIVATE & CONFIDENTIAL" + vbNewLine)
    txtrecipt.Appendtext(" " & vbNewLine)
    txtrecipt.Appendtext("Employer Name: " + vbTab & EmployerTextBox.Text + vbTab + vbTab + vbTab & "PayDate" + vbTab + vbTab & Pay_DateDateTimePicker.Text + vbNewLine)
    txtrecipt.Appendtext("Employee Name: " + vbTab & NameTextBox1.Text)

    txtrecipt.Appendtext("==============================================================================" + vbNewLine)

    txtrecipt.Appendtext(" " & vbNewLine)
    txtrecipt.Appendtext("Basic Salary: " + vbTab & Basic_SalaryTextBox.Text + vbTab & "Absent: " + vbTab & AbsentTextBox.Text + vbTab & "Late: " + LateTextBox.Text + vbTab & "Short Leave: " + Short_LeaveTextBox.Text + vbTab & "Half Day: " + Half_DayTextBox.Text + vbNewLine)
    txtrecipt.Appendtext(" " + vbNewLine + vbNewLine)
    txtrecipt.Appendtext("Payment: " + vbTab + vbTab & PaymentTextBox.Text + vbTab & "Deductions: " + vbTab & DeductionTextBox.Text + vbTab & "Net Pay: " + vbTab & netpay.Text + vbNewLine)

    txtrecipt.Appendtext("==============================================================================" + vbNewLine)

    txtrecipt.Appendtext(" " + vbNewLine + vbNewLine)
    txtrecipt.Appendtext(Today & vbTab + vbTab + vbTab + vbTab + vbTab + vbTab + vbTab + vbTab & TimeOfDay + vbNewLine)
    txtrecipt.Appendtext("==============================================================================" + vbNewLine)
    txtrecipt.Appendtext("                         WITH THANK'S FROM INTERSCAN                          " + vbNewLine)
    txtrecipt.Appendtext("==============================================================================" + vbNewLine)

然后将
appendtext
更改为
AppendLine(“您的字符串”)

为什么要用
C#
标记此项?基于名称
txtrept
和调用
appendtext
的事实,您似乎认为正在使用
文本框
,但错误消息表明(事实上,直截了当地说)你正在使用
按钮。问题很明显。如果你想使用
文本框
,那么就使用
文本框
,如果你正在使用
按钮
,那么你为什么要以显示所有文本开头?顺便说一句,这个词是“收据”,而不是“收据”。即使您使用的是
文本框
,继续这样调用
AppendText
也是愚蠢的,因为这会带来开销。首先在代码中创建整个文本,然后在一次调用中设置
文本
属性。您确实应该学会使用字符串插值和/或
字符串.Format
方法和类似方法。它将使代码更具可读性。
StringBuilder txtrecipt = new StringBuilder ();