真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net打開對(duì)話框 vb 打開文件對(duì)話框

vb.net中用什么方法顯示對(duì)話框?

用msgbox()顯示對(duì)話框

創(chuàng)新互聯(lián)公司專注于企業(yè)成都營銷網(wǎng)站建設(shè)、網(wǎng)站重做改版、烏當(dāng)網(wǎng)站定制設(shè)計(jì)、自適應(yīng)品牌網(wǎng)站建設(shè)、H5技術(shù)、商城網(wǎng)站定制開發(fā)、集團(tuán)公司官網(wǎng)建設(shè)、外貿(mào)網(wǎng)站制作、高端網(wǎng)站制作、響應(yīng)式網(wǎng)頁設(shè)計(jì)等建站業(yè)務(wù),價(jià)格優(yōu)惠性價(jià)比高,為烏當(dāng)?shù)雀鞔蟪鞘刑峁┚W(wǎng)站開發(fā)制作服務(wù)。

msgbox的用法很多,基礎(chǔ)的就是msgbox(“你要顯示的內(nèi)容”)

或者msgbox(“你要顯示的內(nèi)容”,16,"對(duì)話框名稱")'16是對(duì)話框的類型,還有幾個(gè)鍵的組合代碼,這個(gè)你可以

查查

,很多,或者你也可以用提示給出的類型,比如MsgBoxStyle.Exclamation就是顯示錯(cuò)誤對(duì)話框,

vb.net使用打開對(duì)話框,打開一個(gè)文本文件顯示在文本框中,然后對(duì)文本框中的信息進(jìn)行編輯后

讀文件內(nèi)容到TextBox :

Try

Using sr As StreamReader = New StreamReader("C:\\TestFile.txt")

textbox1.Text = sr.ReadToEnd()

End Using

Catch E As Exception

Console.WriteLine(E.Message)

End Try

修改完成后,保存到文件:

Using sw As StreamWriter = New StreamWriter("C:\\TestFile.txt")

sw.Write(textbox1.Text)

sw.Close()

End Using

其中,流構(gòu)造的參數(shù)

New StreamReader("C:\\TestFile.txt")

New StreamWriter("C:\\TestFile.txt")

中的"C:\\TestFile.txt"可以用OpenFileDialog和SaveFileDialog的FileName屬性替換.

Dim openFileDialog1 As New OpenFileDialog()

openFileDialog1.InitialDirectory = "c:\"

openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"

openFileDialog1.FilterIndex = 2

openFileDialog1.RestoreDirectory = True

If openFileDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK Then

Try

Using sr As StreamReader = New StreamReader(openFileDialog1.FileName)

textbox1.Text = sr.ReadToEnd()

End Using

Catch E As Exception

Console.WriteLine(E.Message)

End Try

End If

保存的時(shí)候換成SaveFileDialog就好

VB.NET中,文件對(duì)話框(OpenFileDialog)顯示某種設(shè)定的文件類型需要修改什么屬性?

Filter 屬性設(shè)置當(dāng)前文件名篩選字符串,該字符串確定出現(xiàn)在對(duì)話框的“文件類型”框中的選項(xiàng)。

openFileDialog1.InitialDirectory = "c:\\" ;

openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*" ;

openFileDialog1.FilterIndex = 1 ; // 獲取或設(shè)置文件對(duì)話框中當(dāng)前選定篩選器的索引;

openFileDialog1.RestoreDirectory = true ;

對(duì)于每個(gè)篩選選項(xiàng),篩選器字符串都包含篩選器說明,后接一垂直線條 (|) 和篩選器模式。不同篩選選項(xiàng)的字符串由垂直線條隔開。

VB.net怎么彈出如下類似的對(duì)話框(看圖)?

可以利用msgbox 實(shí)現(xiàn),也可以通過另外的窗體上畫出表格實(shí)現(xiàn)

方法一,利用msgbox:

Private Sub Command1_Click()Dim a As Long, b As Long, c As LongMsgBox "┌────┬────┬────┐" vbCrLf _ "│ 庫存1 │ 庫存2 │ 庫存3 │" vbCrLf _ "├────┼────┼────┤" vbCrLf _ "│" formatstr(a) "│" formatstr(b) "│" formatstr(c) "│" vbCrLf _ "└────┴────┴────┘" End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j) inputStr Space(j) Space((8 - Len(inputStr)) Mod 2)End Function

方法二,利用窗體實(shí)現(xiàn):

’新建form2窗體‘將以下代碼復(fù)制到form2窗體中Private Sub Form_Load()ShowPrint "┌────┬────┬────┐" vbCrLf _ "│ 庫存1 │ 庫存2 │ 庫存3 │" vbCrLf _ "├────┼────┼────┤" vbCrLf _ "│" formatstr(a) "│" formatstr(b) "│" formatstr(c) "│" vbCrLf _ "└────┴────┴────┘" End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j) inputStr Space(j) Space((8 - Len(inputStr)) Mod 2)End Function‘將以下代碼復(fù)制在form1窗體中Private Sub Command1_Click()Form2.ShowEnd Sub


新聞標(biāo)題:vb.net打開對(duì)話框 vb 打開文件對(duì)話框
本文地址:http://weahome.cn/article/dojehsi.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部