自己的类不能将字符串转换为整数

时间:2017-11-25 20:09:42

标签: vb.net

https://imgur.com/a/gaXh4 好吧,我有一个问题是一个非常奇怪的问题。所以我创建了一个新类,它是一种新类型的TextBox。它借助列表跟踪从中创建的对象。这一切都有效,每个我可以得到类的所有对象,但是当我想将TextBox中的字符串转换为整数时我不能这样做,因为它认为它不可转换eventhought字符串只包含数字符号

按钮代码

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    'TextBox1.Text = CInt(SumTextBox1.Text) + CInt(SumTextBox2.Text) 


    For Each item As SumTextBox In SumTextBox.sumList
        Dim textItem As SumTextBox = item
        TextBox1.Text = CInt(TextBox1.Text) + CInt(textItem.Text)
    Next
End Sub



Public Class SumTextBox
Inherits TextBox
Public Shared sumList As New List(Of SumTextBox)


Sub New()
    Size = New Size(90, 10)
    sumList.Add(Me)
End Sub

结束班

1 个答案:

答案 0 :(得分:0)

尝试使用RestClient client = new RestClient(url); RestRequest request = new RestRequest(url_stuff, Method.GET); request.AddHeader(public_key, secret_key); return client.Execute(request).Content; 和textitem.text

相同