看板 Visual_Basic 關於我們 聯絡資訊
狀況: 有一個ListBox寬度固定 有一個TextBox寬度與Listbox相同,並調整成MultiLIne 有一個CommandButton用來執行效果 需求 先在TextBox中輸入一句話,並造成因為句子太長而 自動換行的情形。例如: |I am so stupid that I can't |(| |表示Textbox寬度) |understand what you say. | 上下兩句並沒有用Enter分行,是因為understand太長而自動換行的 接著按下CommandButton後,期望ListBox可新增資料 一為"I am so stupid that I can't" 一為"understand what you say." -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.115.65.233
fumizuki:算他bytes數 太長就截掉 61.222.155.162 06/21
fumizuki:截掉時找最後一個空白再截 61.222.155.162 06/21
Uld:謝謝你的回答,如果句子裡有混和中文呢? 140.115.65.233 06/21
fumizuki:用 strconv() 轉換 61.222.155.162 06/21
fumizuki:lenb() 算 bytes數 61.222.155.162 06/21
fumizuki:如果 asc 碼小於零為中文字 61.222.155.162 06/21
Uld:謝謝 140.115.65.233 06/21