[.NET] VS2008 richtextbox的幾個小問題
請輸入專案類型(網站專案或者應用程式專案):vs2008
1.我想做出像記事本一樣可以有自動換行的功能,請問該怎麼做?
我想用MenuStrip_Click來執行,
本來的想法是當文章內容遇上句號就自動斷行(IF....EndIf),
可是做不出來┬▽┬
上網查了一下,我是不是應該用循序抓取出句號再+vbCrLf這樣比較好?("。"+vbCrLf)
只是特別抓出某字元再斷行的程式我寫不出來......
2.開啟舊檔的功能(已解決)
按照課本的方法寫下這段程式
Dim st As String
dlgopen.Filter = "文書檔(*.txt)|*.txt|所有檔案(*.*)|*.*"
dlgopen.FilterIndex = 1
dlgopen.RestoreDirectory = True
dlgopen.DefaultExt = ".txt"
If dlgopen.ShowDialog() = Windows.Forms.DialogResult.OK Then
txtnote.Text = ""
pf_name = dlgopen.FileName
f_name = IO.Path.GetFileNameWithoutExtension(pf_name)
f_num = FreeFile()
FileOpen(f_num, pf_name, OpenMode.Input)
Do While Not EOF(f_num)
Input(f_num, st)
txtnote.Text = txtnote.Text + st
Loop
Me.Text = f_name & "-記事本"
End If
FileClose(f_num)
可是在倒數第六行 Input(f_num,st) 的地方會出現錯誤
像這樣↓
變數 'st' 已在指派值之前透過傳址方式傳遞。
可能會在執行階段產生 null 參考例外狀況。
在一開始有宣告
Public Class Form1
Dim pf_name As String
Dim f_name As String
Dim f_num As Integer
像這樣↑
以上兩個問題請大家幫幫忙 謝謝! ^▽^
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 210.241.89.150
→
06/23 14:42, , 1F
06/23 14:42, 1F
→
06/23 14:44, , 2F
06/23 14:44, 2F
→
06/23 14:45, , 3F
06/23 14:45, 3F
→
06/23 14:54, , 4F
06/23 14:54, 4F
→
06/23 15:00, , 5F
06/23 15:00, 5F
→
06/23 23:09, , 6F
06/23 23:09, 6F
※ 編輯: ai15 來自: 218.174.19.192 (06/23 23:13)
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 2 篇):