1、新建一個標準的VB EXE工程,只有一個Form,F(xiàn)orm上有兩個按鈕:Command1和Command2。
我們提供的服務有:網(wǎng)站設(shè)計制作、成都做網(wǎng)站、微信公眾號開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認證、湘西土家族ssl等。為近千家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務,是有科學管理、有技術(shù)的湘西土家族網(wǎng)站制作公司
2、雙擊Command1添加如下代碼
Private Sub Command1_Click()
Dim strFile? ? ?As String
Dim intFile? ? ?As Integer
Dim strData? ? ?As String
strFile = "c:\學生成績.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)試代碼,點擊Command1,進入單步調(diào)試功能,
4、多次按下F8或直接按下F5運行完成,就完成了讀取文本文件內(nèi)容并輸出到立即窗口。
VB.NET編程讀取txt文本文檔中的數(shù)據(jù),并把數(shù)據(jù)保存為數(shù)組,代碼如下:
'寫配件文件
Private?Sub?saveIni(ByVal?filePath?As?String,?ByVal?str?As?String)
Dim?sw?As?StreamWriter?=?New?StreamWriter(filePath,?True)?'true是指以追加的方式打開指定文件
sw.WriteLine(str)
sw.Flush()
sw.Close()
sw?=?Nothing
End?Sub
'讀配件文件
Private?Function?readIni(ByVal?filePath?As?String)
Dim?iniDt?As?New?DataTable
iniDt.Columns.Add("text")
iniDt.Columns.Add("value")
Try
Dim?sr?As?StreamReader?=?New?StreamReader(filePath,?System.Text.Encoding.Default)
Dim?line?As?String?=?""
While?Not?sr.EndOfStream
Dim?str?=?sr.ReadLine()'讀取當前行
iniDt.Rows.Add(New?String()?{
str(0),
str(1)
})
End?While
sr.Close()
sr?=?Nothing
Catch?ex?As?Exception
End?Try
Return?iniDt
End?Function
1、實現(xiàn)上傳按鈕方法代碼。
2、判斷圖片對象是否為空代碼。
3、取得數(shù)據(jù)庫字段 dt.Rows(0)("Pic")方法代碼。
4、字節(jié)數(shù)組轉(zhuǎn)換為Image類型方法代碼。
5、處理SQL中操作Image類型方法代碼。
6、實現(xiàn)的上傳結(jié)果。
Public Function webCaptureContent(ByVal mWebsiteUrl As String, ByVal mWebsiteType As Boolean) As String
'啟動一次具體的數(shù)據(jù)采集工作,返回采集到的HTML內(nèi)容:要求必須輸入帶://的全地址數(shù)據(jù)
On Error Resume Next
Dim Str_WebContent As String = "請輸入查找網(wǎng)站地址."
Dim wb As WebClient = New WebClient() '//創(chuàng)建一個WebClient實例
If mWebsiteUrl.IndexOf("://") 0 Then
'//獲取或設(shè)置用于對向 Internet 資源的請求進行身份驗證的網(wǎng)絡(luò)憑據(jù)。(可有可無)
wb.Credentials = CredentialCache.DefaultCredentials
'//從資源下載數(shù)據(jù)并返回字節(jié)數(shù)組。(加@是因為網(wǎng)址中間有"/"符號)
Dim pagedata As Object = wb.DownloadData(mWebsiteUrl)
'//轉(zhuǎn)換字符
If mWebsiteType Then
Str_WebContent = Encoding.Default.GetString(pagedata)
Else
Str_WebContent = Encoding.UTF8.GetString(pagedata)
End If
End If
Return Str_WebContent '提取出來新聞內(nèi)容,刪除Body前后的多余內(nèi)容,同時補充上該 Body標記,形成完整的內(nèi)容 Str_WebContent '
End Function
新聞名稱:vb.net讀取數(shù)據(jù) vb讀取數(shù)據(jù)庫
轉(zhuǎn)載來源:http://www.rwnh.cn/article14/hhgede.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供營銷型網(wǎng)站建設(shè)、、微信公眾號、定制網(wǎng)站、做網(wǎng)站、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)