小弟写了一段代码:
text4.Text="正在播放"&vbcrlf &"《"&text3.text& "》"&"中的" & vbcrlf & list1.text &_
vbcrlf&"该列表共计:"&vbcrlf & list1.listcount&"部电影"
想在text4.text中显示如下内容:
正在播放
《经典收藏》中的 ‘text3.text提供列表名’
卧虎藏龙 ‘list1.text选中项提供电影名’
该列表共计:
35部电影 ‘list1.listcount 提供’
但是这段代码总提示有问题,请高手帮忙检查一下。
VB 如何在text中显示多行内容?
答案:3 悬赏:50
解决时间 2021-04-27 17:07
- 提问者网友:霸气大叔
- 2021-04-27 02:37
最佳答案
- 二级知识专家网友:山鬼偶尔也合群
- 2021-04-27 03:47
Text4.Text = "正在播放" & vbCrLf & "《" & text3.Text & "》" & "中的" & vbCrLf & list1.Text & _
vbCrLf & "该列表共计:" & vbCrLf & list1.ListCount & "部电影"
改成这样就好了,&连接时左右都要有空格
vbCrLf & "该列表共计:" & vbCrLf & list1.ListCount & "部电影"
改成这样就好了,&连接时左右都要有空格
全部回答
- 1楼网友:爱情是怎么炼成的
- 2021-04-27 04:49
Text4.Text = "正在播放" & vbCrLf & "《" & Text3.Text & "》中的" & vbCrLf & List1.Text & _
vbCrLf & "该列表共计:" & vbCrLf & List1.ListCount & "部电影"
你的代码主要有两个错误:
1、作为字符串连接符的&的前后一定要加空格;
2、作为换行连接符的_的前面一定要加空格。
- 2楼网友:情战凌云蔡小葵
- 2021-04-27 04:21
dim filebuffer as new collection
const filename = "c:\1.txt" '文件名自己改一下
dim text_1 as string
dim text_2 as string
private sub read() '读入文件
'可以在窗体load事件中或按钮事件中读入文件:
dim filenumber as integer
filenumber = freefile
open filename for input as #filenumber
dim strline as string
do until eof(filenumber)
line input #filenumber, strline
filebuffer.add strline
loop '把文件行读入到集合中
text1 = split(filebuffer.item(3), "=")(1)
text2 = split(filebuffer.item(4), "=")(1) '写入文本框
text_1 = text1
text_2 = text2
close #filenumber
end sub
'-----------------------------------
private sub save() '保存文件
dim a
a = split(filebuffer.item(3), "=")
a(1) = text1
filebuffer.remove 3
filebuffer.add join(a, "="), , 3
a = split(filebuffer.item(4), "=")
a(1) = text2
filebuffer.remove 4
filebuffer.add join(a, "="), , 4
dim filenumber as integer
filenumber = freefile
open filename for output as #filenumber
dim i as integer
for i = 1 to filebuffer.count
print #filenumber, filebuffer.item(i)
next
close #filenumber
end sub
'-----------------------------------------
private sub form_load()
read '你也可以放在按钮事件中读取
end sub
'--------------------------
private sub form_unload(cancel as integer)
if text1 <> text_1 or text2 <> text_2 then save
end sub
'---------------------------
private sub text1_validate(cancel as boolean)
if text1 <> text_1 then
save
text_1 = text1
end if
end sub
'----------------------------
private sub text2_validate(cancel as boolean)
if text2 <> text_2 then
save
text_2 = text2
end if
end sub'如果仅仅是在关闭窗口时更新文件,把文本框causesvalidation设置为false,否则设为true
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息