在TextBox中显示对象类型? [英] Show an Object type in a TextBox ?

查看:163
本文介绍了在TextBox中显示对象类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的代码:

将enc作为新的System.Text.UTF8Encoding()
TextBox.Text = enc.GetString(数据)

数据的类型是来自.dll 文件的对象,该对象包含一些日期,例如网页地址为www ......".

但是该代码无法在文本框中显示所有数据,只会显示第一个字母(T).我该怎么办?

The code I used:

Dim enc As New System.Text.UTF8Encoding()
TextBox.Text = enc.GetString(datas)

datas''s type is Object that coming from a .dll file that contain some date such as "The web page address is www......"

but that code can''t show all datas in textbox, only first letter (T) appear. what do i do?

推荐答案

请核实几件事:

来自您的代码:
Kindly verify few things:

From you code:
Dim enc As New System.Text.UTF8Encoding()
TextBox.Text = enc.GetString(datas)



在两条线之间放置一条线,看看会得到什么:



place a line in between the two lines and see what you get:

Dim enc As New System.Text.UTF8Encoding()
' You should receive a full text in "Output Window" if your data comes perfectly.
System.Diagnostic.Debug.Print(datas) 
TextBox.Text = enc.GetString(datas)



另外,请检查您的TextBox的 MaxLength 属性.它不应该1.

这是有关如何使用GetString()的示例代码:



Also, please check MaxLength property of your TextBox. It should not 1.

Here is a sample code for how to use GetString():

'Here data is converted to bytes for sending...
Dim datas As String = "The web page address is www.google.com"
Dim b() As Byte = Encoding.UTF8.GetBytes(datas.ToCharArray)


'Assume 'b' is a byte array coming from some .dll as in your case
'Here data is converted back to String USING GETSTRING()
Dim StreamData As String = Encoding.UTF8.GetString(b)
System.Diagnostics.Debug.Print(StreamData)


这篇关于在TextBox中显示对象类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆