VB.NET中.LISTBOX.ITEMS.ADD的问题.

answer_java 2008-07-29 09:31:50
ds = clsCommon.GetData(sqlStr)
dt = ds.Tables(0)
dr = dt.CreateDataReader()
While dr.Read
If dr.IsDBNull(0) = False And dr.IsDBNull(2) = False Then
'Format ArticleID and TimingID
'result value add to Arraylist
snum = 22
c_moji = dr.GetString(1)
Call Char_check(c_moji, snum)
'Add to ArticleList
Me.lstArticle.Items.Add(dr.GetString(1) & Space(snum) & dr.GetString(3))

End If
End While

-----Char_check-----

Public Sub Char_check(ByRef c_moji As String, ByRef spc_su As Integer)
'Variable for byte type conversion
Dim enco As System.Text.Encoding = System.Text.Encoding.Unicode
Dim Unibyte() As Byte
Dim snum As Integer ' Number of space of stuff in back
Dim han_su, zen_su As Integer ' Em-size and one-byte character number counter
Dim i As Integer ' Counter

'The received character string is converted into byte type.
Unibyte = enco.GetBytes(c_moji)

'Initialization of variable
han_su = 0
zen_su = 0
For i = 1 To Unibyte.Length - 1 Step 2

'' When the logic em-size that distinguishes signs of em-size is distinguished, here is made On.

If (Unibyte(i) = &H0 And (&H20 <= Unibyte(i - 1) And Unibyte(i - 1) <= &H7D)) Or _
(Unibyte(i) = &HFF And (&H61 <= Unibyte(i - 1) And Unibyte(i - 1) <= &H9F)) Then

'--------------------------------------------------------------
'When em-size is distinguished for the alphanumeric character,
'the sign, and the normal-width katakana, here is turned off.
'--------------------------------------------------------------

'One-byte character
han_su += 1
Else
'Em-size character
zen_su += 1
End If
Next

'The number of stuffed space is calculated from the character distinction.
snum = spc_su
snum = snum - ((zen_su * 2) + han_su)


'When the character string exceeds the display area
If snum < 1 Then
snum = 1
'c_moji = enco.GetString(Unibyte, 1, 24)
End If

'The number of stuffed space is returned.
spc_su = snum
End Sub

将数据库里两个字段的数据加起来ADD到LISTBOX里.但是通过上面的那个方法取出来的数据不能达到我预期的效果.
预想得到的效果是:
品目      使用時期
品目一 使用时期一
品目二 使用时期二

请各位高手指导一下....
谢谢....
...全文
217 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
answer_java 2008-07-30
  • 打赏
  • 举报
回复
兄弟们.谢谢.可以了.
找到原因了.
控件里的字体没设置..汗...
谢谢各位了.
answer_java 2008-07-30
  • 打赏
  • 举报
回复
嗯...两个LISTBOX..

跟字母排序没有关系吧?
yanlongwuhui 2008-07-30
  • 打赏
  • 举报
回复
两个LISTBOX?是不是sorted设置成TRUE了
answer_java 2008-07-30
  • 打赏
  • 举报
回复
可是在LISTBOX里显示出来的结果错位了....

我弄了两个LISTBOX..
第一个LISTBOX显示的是标题...
第二个是取出来的内容..
wangcong207 2008-07-29
  • 打赏
  • 举报
回复
我运行了你的代码没有问题啊
运行后的显示
1 wang
2 jia
3 li
answer_java 2008-07-29
  • 打赏
  • 举报
回复
第一列跟第二列之间的空格总是控制不好.
ADD的字符放到记事本里,是可以对齐显示的..

请高手们指导一下..小弟感激不尽..

16,717

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧