日韩在线不卡一区二区三区四区五区,欧美视频一区二区三,欧美视频中文字幕一区二区,高端 精品 国产 探花,亚欧无吗一二三四五六区
RELATEED CONSULTING
相關(guān)咨詢(xún)
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
vb.net讀取文件流,vbnet讀取文件內(nèi)容

vb.net 二進(jìn)制讀取文件

VB.NET打開(kāi)二進(jìn)制文件用fileopen完成,打開(kāi)二進(jìn)制文件的形式為:openmode.binary

專(zhuān)注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)資陽(yáng)免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了上1000家企業(yè)的穩(wěn)健成長(zhǎng),幫助中小企業(yè)通過(guò)網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

讀取二進(jìn)制文件用的是fileget方法,寫(xiě)入二進(jìn)制文件用的是fileput方法。

應(yīng)用示例:將一批隨機(jī)數(shù)保存在一個(gè)dat文件中,然后再將其提取到文本框中。

二進(jìn)制文件的讀寫(xiě)一批隨機(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

vb.net中,讀取和寫(xiě)入文件

寫(xiě)入:Dim sr As New IO.StreamWriter(Application.StartupPath "/寫(xiě)入的文本.txt")

sr.WriteLine("寫(xiě)入的內(nèi)容") sr.Close()讀?。篒f (File.Exists(Application.StartupPath "/msg.txt")) Then

Dim fm As New IO.FileStream(Application.StartupPath "/讀取的文本.txt", FileMode.Open)

Dim sr As IO.StreamReader = New IO.StreamReader(fm)

Do While sr.Peek() = 0

TextBox1.Text = sr.ReadLine() (讀取文本到文本框)

Loop end if

vb.net讀取文件流

dim filename as string = "文件名" Using myfilestream As New FileStream(FileName, FileMode.Open, FileAccess.Read)

Dim data() As Byte

ReDim data(myfilestream.Length - 1)

myfilestream.Read(data, 0, myfilestream.Length)

myfilestream.Close()

' data是你要的結(jié)果,為byte(), End Using

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開(kāi)始單步調(diào)試代碼,點(diǎn)擊Command1,進(jìn)入單步調(diào)試功能,

4、多次按下F8或直接按下F5運(yùn)行完成,就完成了讀取文本文件內(nèi)容并輸出到立即窗口。


分享題目:vb.net讀取文件流,vbnet讀取文件內(nèi)容
轉(zhuǎn)載注明:http://biofuelwatch.net/article/hddjhc.html
日韩在线不卡一区二区三区四区五区,欧美视频一区二区三,欧美视频中文字幕一区二区,高端 精品 国产 探花,亚欧无吗一二三四五六区