vb OpenFileDialog1怎么用啊,
求打开任意路径记事本文件并显示其内容,本人这方面没什么基础,求完整代码,最好拷过来就能运行。我现在用的编程工具是vb.net2005,谢啦。...
求打开任意路径记事本文件并显示其内容,本人这方面没什么基础,求完整代码,最好拷过来就能运行。我现在用的编程工具是vb.net 2005,谢啦。
展开
展开全部
OpenFileDialog是VB.Net窗体应用程序的一个控件,在这个控件显示的对话框中,用户执行打开文件操作。OpenFileDialog对话的使用方法如下
(1)在Visual Studio中建立一个“Windows 应用程序项目”——WindowsApplication1
(2)在Form1上布置一个Label、一个TextBox,一个Button和一个OpenFileDialog
设置TextBox1属性如下:
设置OpenFileDialog1属性如下
(3)窗体代码Form1.vb
Imports System.Windows.Forms
Imports System.IO
Public Class Form1
Private Sub Button1_Click(sender As Object, _
e As EventArgs) Handles Button1.Click
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
'清空TextBox1
TextBox1.Clear()
'读文本文件
Dim lines As String()
lines = File.ReadAllLines(OpenFileDialog1.FileName)
'显示文件内容
Dim s As String
For Each s In lines
TextBox1.AppendText(s + Environment.NewLine)
Next
'显示打开的文件名
Label1.Text = OpenFileDialog1.FileName
End If
End Sub
Private Sub Form1_Load(sender As Object, _
e As EventArgs) Handles MyBase.Load
Label1.Text = String.Empty
Button1.Text ="打开文本文件"
End Sub
End Class
(4)运行
启动时
点击“打开文本文件”按钮
打开并显示文件
展开全部
在窗体的Button按钮添加如下代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myStream As System.IO.Stream
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
OpenFileDialog1.RestoreDirectory = True
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
MsgBox(OpenFileDialog1.FileName)
myStream = OpenFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then
MessageBox.Show(myStream.Length.ToString)
myStream.Close()
End If
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim myStream As System.IO.Stream
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
OpenFileDialog1.RestoreDirectory = True
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
MsgBox(OpenFileDialog1.FileName)
myStream = OpenFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then
MessageBox.Show(myStream.Length.ToString)
myStream.Close()
End If
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select a.fromstepid,
case a.isauto when 1 then b.tostepid else a.tostepid end as tostepid
from step a
left join step b on a.tostepid=b.fromstepid
where a.fromstepid not in
(select tostepid from step where isauto=1)
SQL Server2005,测试通过
case a.isauto when 1 then b.tostepid else a.tostepid end as tostepid
from step a
left join step b on a.tostepid=b.fromstepid
where a.fromstepid not in
(select tostepid from step where isauto=1)
SQL Server2005,测试通过
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询