新聞中心
vb.net怎么實(shí)現(xiàn)讀取指定WORD文檔中的內(nèi)容
添加spire.doc.dll為引用,在vb.net中讀取指定word文檔的內(nèi)容到?txt文件,代碼示例如下:
萬(wàn)寧ssl適用于網(wǎng)站、小程序/APP、API接口等需要進(jìn)行數(shù)據(jù)傳輸應(yīng)用場(chǎng)景,ssl證書未來(lái)市場(chǎng)廣闊!成為成都創(chuàng)新互聯(lián)公司的ssl證書銷售渠道,可以享受市場(chǎng)價(jià)格4-6折優(yōu)惠!如果有意向歡迎電話聯(lián)系或者加微信:18982081108(備注:SSL證書合作)期待與您的合作!
'加載Word文檔
Dim doc As Document = New Documentdocument.LoadFromFile("測(cè)試文檔.docx")
'使用GetText方法獲取文檔中的所有文本
Dim s As String = doc.GetText
File.WriteAllText("文本1.txt", s.ToString)
VB.net 讀取文本文件?
1、實(shí)現(xiàn)上傳按鈕方法代碼。
2、判斷圖片對(duì)象是否為空代碼。
3、取得數(shù)據(jù)庫(kù)字段 dt.Rows(0)("Pic")方法代碼。
4、字節(jié)數(shù)組轉(zhuǎn)換為Image類型方法代碼。
5、處理SQL中操作Image類型方法代碼。
6、實(shí)現(xiàn)的上傳結(jié)果。
VB.net窗體設(shè)計(jì)中,如何讀取.txt文件中的數(shù)據(jù)?
1、新建一個(gè)標(biāo)準(zhǔn)的VB EXE工程,只有一個(gè)Form,F(xiàn)orm上有兩個(gè)按鈕:Command1和Command2。
2、雙擊Command1添加如下代碼
Private Sub Command1_Click()
Dim strFile? ? ?As String
Dim intFile? ? ?As Integer
Dim strData? ? ?As String
strFile = "c:\學(xué)生成績(jī).txt"
intFile = FreeFile
Open strFile For Input As intFile
strData = StrConv(InputB(FileLen(strFile), intFile), vbUnicode)
Debug.Print strData
Close intFile
End Sub
3、按F8開始單步調(diào)試代碼,點(diǎn)擊Command1,進(jìn)入單步調(diào)試功能,
4、多次按下F8或直接按下F5運(yùn)行完成,就完成了讀取文本文件內(nèi)容并輸出到立即窗口。
vb.net 二進(jìn)制讀取文件
VB.NET打開二進(jìn)制文件用fileopen完成,打開二進(jìn)制文件的形式為:openmode.binary
讀取二進(jìn)制文件用的是fileget方法,寫入二進(jìn)制文件用的是fileput方法。
應(yīng)用示例:將一批隨機(jī)數(shù)保存在一個(gè)dat文件中,然后再將其提取到文本框中。
二進(jìn)制文件的讀寫一批隨機(jī)數(shù)的存取,程序?yàn)椋?/p>
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, i, fn As Integer
Dim s As String = ""
fn = FreeFile()
FileOpen(fn, "d:\data.dat", OpenMode.Binary)
For i = 1 To 8
x = Int(Rnd() * 100)
s = s + Str(x)
FilePut(fn, x)
Next
FileClose(fn)
TextBox1.Text = s
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim x, fn As Integer
Dim s As String = ""
fn = FreeFile()
FileOpen(fn, "d:\data.dat", OpenMode.Binary)
Do While Not EOF(fn)
FileGet(fn, x)
s = s + Str(x) + " "
Loop
FileClose(fn)
TextBox1.Text = s
End Sub
網(wǎng)站標(biāo)題:vb.net讀取文件 vbs 讀取文件
當(dāng)前URL:http://www.dlmjj.cn/article/dogsips.html