註冊
登錄
首頁
論壇版規
禁止列表
說明
地圖
數位書香
私人消息 (0)
公共消息 (0)
論壇任務 (0)
系統消息 (0)
好友消息 (0)
帖子消息 (0)
麻辣家族討論版版
»
VB 與 VB.Net
» [VB2010] txt 簡易 讀 寫 視窗
返回列表
下一主題
上一主題
發帖
[分享]
[VB2010] txt 簡易 讀 寫 視窗
mark15jill
發短消息
加為好友
mark15jill
(隨風飄蕩的羽毛)
當前離線
[御用]潛水艇
UID
4247
帖子
852
主題
79
精華
0
積分
918
金錢
918
點名
0
作業系統
Windows 7 , XP
軟體版本
Office 2007, Office 2003,Office 2010,YoZo Office
閱讀權限
50
性別
男
來自
宇宙
在線時間
414 小時
註冊時間
2011-4-8
最後登錄
2024-2-21
暱稱:
隨風飄蕩的羽毛
頭銜:
[御用]潛水艇
高中生
帖子
852
主題
79
精華
0
積分
918
點名
0
作業系統
Windows 7 , XP
軟體版本
Office 2007, Office 2003,Office 2010,YoZo Office
閱讀權限
50
性別
男
來自
宇宙
註冊時間
2011-4-8
最後登錄
2024-2-21
1
#
跳轉到
»
倒序看帖
打印
字體大小:
t
T
發表於 2013-3-7 13:45
|
只看該作者
[分享]
[VB2010] txt 簡易 讀 寫 視窗
預設目錄:D:\123.txt
下載
(196.28 KB)
2013-3-7 13:44
有問題可以問...
此帖僅提供基本讀寫功能,並無提供關鍵字搜尋功能
Imports System.IO
'方法1
Public Class Form1
Dim lab As New Label
Dim bum1, bum2 As New Button
Dim te1, te2 As New TextBox
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Me
.Controls.Add(lab)
.Height = 600
.Width = 800
.FormBorderStyle = Windows.Forms.FormBorderStyle.Fixed3D
With .Controls
.Add(te1) : .Add(te2) : .Add(bum1) : .Add(bum2)
End With
End With
With te1
.ScrollBars = ScrollBars.Both
.BorderStyle = BorderStyle.Fixed3D
.Width = (Me.Width - 40) / 2
.Height = Me.Height - 150
.Location = New Point(10, 100)
.Multiline = True
End With
With te2
.ScrollBars = ScrollBars.Both
.BorderStyle = BorderStyle.Fixed3D
.Width = (Me.Width - 40) / 2
.Height = Me.Height - 150
.Location = New Point(10 + te1.Width + te1.Location.X, 100)
.Multiline = True
End With
With bum1
.TextAlign = ContentAlignment.MiddleCenter
.Text = "寫"
.Width = 100
.Height = 40
.Location = New Point(((te1.Location.X + te1.Width) / 2) - 50, 50)
End With
With bum2
.TextAlign = ContentAlignment.MiddleCenter
.Text = "讀"
.Width = 100
.Height = 40
.Location = New Point((Me.Width - te2.Location.X - 10) + ((te2.Width + te2.Location.X) / 4), 50)
End With
With lab
.TextAlign = ContentAlignment.MiddleCenter
.Location = New Point((Me.Width / 2) - 100, 10)
.Width = 200
.Height = 25
.AutoSize = False
.BackColor = Color.Peru
.BorderStyle = BorderStyle.Fixed3D
.Text = "先寫後讀"
End With
AddHandler bum1.Click, AddressOf button1_Click
AddHandler bum2.Click, AddressOf button2_Click
End Sub
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim kk1 As String
kk1 = te1.Text
Dim FileNum As Integer
Dim strTemp As String
FileNum = FreeFile()
FileOpen(FileNum, "D:\123.txt", OpenMode.Output)
strTemp = kk1
PrintLine(FileNum, strTemp)
FileClose(FileNum)
End Sub
Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim FileNum As Integer
Dim strTemp As String
FileNum = FreeFile()
FileOpen(FileNum, "D:\123.txt", OpenMode.Input)
Do Until EOF(FileNum)
te2.Text = LineInput(FileNum) & vbNewLine
Loop
FileClose(FileNum)
End Sub
End Class
複製代碼
樓主熱帖
Office 2010 月曆控制項新增
多筆EXCEL搜尋的用法[已解決 2011-05-11]
請問1些搬移的問題
[閒聊]編寫程式時,建議的幾件事情 "要做"
關於儲存格 兩段的問題
關於篩選與其背景顏色設定問題
想請問關於一些自動化格式設定的問題
無聊作的小時鐘...
請問是否可以用VBA 自動檢查重複名稱
分享個無聊小程式...
收藏
分享
多做多想多學習,少看少錯少迷途
多做=多多練習,多多編寫。
多想=想想為什麼人家程式要那樣寫,如果換成自己,又會怎寫。
多學習=學習人家的發問並解答,學習人家的寫法
少看=只看不做也枉然
靜思自在 :
地上種了菜,就不易長草;心中有善,就不易生惡。
返回列表
下一主題
上一主題
EXCEL專屬討論區
Excelㄧ般區
Excel程式區
進階應用專區
OFFICE 系列
Word
PowerPoint
Access
Office不分區
程式語言
VB 與 VB.Net
C 與 C#
Java 與 J#
程式設計不分區
資料庫
ORACLE
My SQL
MS SQL
網頁設計
ASP 與 ASP.NET
PHP
PHP+MySQL 入門實作
JavaScript
FLASH / ActionScript
HTM/ HTML/ CSS
網頁設計不分區
電腦與作業系統
電腦各種硬體討論
一般電腦軟體討論
論壇事務
管理公告
投訴反映
新手測試
愛 • 生活
公益佈告欄
生活與感動
[收藏此主題]
[關注此主題的新回復]
[通過 QQ、MSN 分享給朋友]
申請友情鏈接
Facebook粉絲