VB文本编辑器(可以改变字体,有背景颜色,)我保存成功,但是怎么都打不开,求大神指教
PrivateSub打开_Click()DimfnAsStringDimsAsStringDims1AsString'Dimfontname1AsString'Dimfo...
Private Sub 打开_Click()
Dim fn As String
Dim s As String
Dim s1 As String
'Dim fontname1 As String
'Dim fontsize1 As Integer
'
'Dim fontbold1 As Boolean
'Dim fontitalic1 As Boolean
'Dim backclolor1 As Long
'Dim foreclolor1 As Long
'Dim underline1 As Boolean
'Dim strikethru1 As Boolean
colog1.Filter = "文本文件|*.txt"
colog1.ShowOpen
Text1.Text = ""
fn = colog1.FileName
Open fn For Output As #1
Do While Not EOF(1)
Line Input #1, s1
s = s & s1 & Chr(13) & Chr(10)
Loop
Text1 = s
Close #1
' Text1.FontName = FontName
' Text1.FontSize = FontSize
' Text1.FontBold = FontBold
' Text1.FontItalic = FontItalic
'' Text1.BackColor = backclolor
'' Text1.ForeColor = foreclolor
' Text1.FontUnderline = Underline
' Text1.FontStrikethru = strikethru
'Close #1
End Sub 展开
Dim fn As String
Dim s As String
Dim s1 As String
'Dim fontname1 As String
'Dim fontsize1 As Integer
'
'Dim fontbold1 As Boolean
'Dim fontitalic1 As Boolean
'Dim backclolor1 As Long
'Dim foreclolor1 As Long
'Dim underline1 As Boolean
'Dim strikethru1 As Boolean
colog1.Filter = "文本文件|*.txt"
colog1.ShowOpen
Text1.Text = ""
fn = colog1.FileName
Open fn For Output As #1
Do While Not EOF(1)
Line Input #1, s1
s = s & s1 & Chr(13) & Chr(10)
Loop
Text1 = s
Close #1
' Text1.FontName = FontName
' Text1.FontSize = FontSize
' Text1.FontBold = FontBold
' Text1.FontItalic = FontItalic
'' Text1.BackColor = backclolor
'' Text1.ForeColor = foreclolor
' Text1.FontUnderline = Underline
' Text1.FontStrikethru = strikethru
'Close #1
End Sub 展开
展开全部
文件打开语句(open)不对,你写的是用作输出的(output),应该是for input
追问
谢了,还有一个问题,我需要的是可以设置背景颜色的文本,我保存的文本为(在电脑的文本显示如下):
"123","新宋体",36,#TRUE#,#TRUE#,4259584,0,#TRUE#,#TRUE#
但是打开还是这样显示
怎么让它只显示 123 然后字体颜色也和保存的一样?
追答
怎么写入,就怎么读进(input方式而不是lineinput),将写入的值读到相应的变量中,然后对应给text控件的属性赋值。如果一定要lineinput读入,就将读入值用split分解到不同变量,再相应处理。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询