copyright 1999 - 2014 by heinz prelle - hannover  - lenbachstraße 42 - www.visual-basic5.de | impressum
'Beispiel: VB .Net - Dateinamen als Titeltext verwenden

Option Explicit On
Option Strict On

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With Me
            .Text = "Dateinamen als Titeltext verwenden"
            .CenterToScreen()
            .Button1.Text = "Test..."
        End With
    End Sub

    Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim ofd As OpenFileDialog = New OpenFileDialog
        With ofd
            .Filter = "*.txt|*.txt"
            If .ShowDialog = Windows.Forms.DialogResult.OK And .FileName <> "" Then
                Using sr As IO.StreamReader = New IO.StreamReader(.FileName)
                    Me.RichTextBox1.Text = sr.ReadToEnd()
                End Using
            End If
            With Me
                .Text = Application.ProductName() & " - " & IO.Path.GetFileName(ofd.FileName())
            End With
        End With
    End Sub
End Class
Sourcecode Visual Basic