Jump to content

VB 6.0 Programmierung


Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Recommended Posts

Hallo, ich hoffe, jemand kennt sich ein bisschen mit visual basic 6.0 aus...

 

ich möchte z.B einen geschriebenen text

name = Text1.text

 

speichern...und zwar soll sich dann wie bei windows ein kleines fenster öffnen, wo ich dann bestimmen kann, als was ich es speichern will und den ort, wo ich es speichern kann...

 

wär cool, wenn mir jemand helfen kann...

 

cya...

Link to comment

Das sieht etwa so aus...

 

'File Open /Save Dialoge

'zunächst die benötigten API-Deklarationen

Private Type OPENFILENAME

lStructSize As Long

hwndOwner As Long

hInstance As Long

lpstrFilter As String

lpstrCustomFilter As String

nMaxCustFilter As Long

nFilterIndex As Long

lpstrFile As String

nMaxFile As Long

lpstrFileTitle As String

nMaxFileTitle As Long

lpstrInitialDir As String

lpstrTitle As String

flags As Long

nFileOffset As Integer

nFileExtension As Integer

lpstrDefExt As String

lCustData As Long

lpfnHook As Long

lpTemplateName As String

End Type

 

Private Const OFN_READONLY = &H1

Private Const OFN_OVERWRITEPROMPT = &H2

Private Const OFN_HIDEREADONLY = &H4

Private Const OFN_NOCHANGEDIR = &H8

Private Const OFN_SHOWHELP = &H10

Private Const OFN_ENABLEHOOK = &H20

Private Const OFN_ENABLETEMPLATE = &H40

Private Const OFN_ENABLETEMPLATEHANDLE = &H80

Private Const OFN_NOVALIDATE = &H100

Private Const OFN_ALLOWMULTISELECT = &H200

Private Const OFN_EXTENSIONDIFFERENT = &H400

Private Const OFN_PATHMUSTEXIST = &H800

Private Const OFN_FILEMUSTEXIST = &H1000

Private Const OFN_CREATEPROMPT = &H2000

Private Const OFN_SHAREAWARE = &H4000

Private Const OFN_NOREADONLYRETURN = &H8000

Private Const OFN_NOTESTFILECREATE = &H10000

Private Const OFN_NONETWORKBUTTON = &H20000

Private Const OFN_NOLONGNAMES = &H40000

Private Const OFN_EXPLORER = &H80000

Private Const OFN_NODEREFERENCELINKS = &H100000

Private Const OFN_LONGNAMES = &H200000

Private Const OFN_SHAREFALLTHROUGH = 2

Private Const OFN_SHARENOWARN = 1

Private Const OFN_SHAREWARN = 0

 

Private Declare Function GetSaveFileName Lib "comdlg32.dll" _

Alias "GetSaveFileNameA" (pOpenfilename As OPENFILENAME) _

As Long

Private Declare Function GetOpenFileName Lib "comdlg32.dll" _

Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) _

As Long

 

...

....

 

 

code

 

 

'Speichern-Dialog

Public Function ShowSaveDlg(f As Form, strFilter As String, _

strTitel As String, strInitDir As String) As String

 

Dim lngOpenFileName As OPENFILENAME

Dim lngAnt As Long

 

With lngOpenFileName

.lStructSize = Len(lngOpenFileName)

.hwndOwner = f.hWnd

.hInstance = App.hInstance

If Right$(strFilter, 1) <> "|" Then _

strFilter = strFilter + "|"

 

For lngAnt = 1 To Len(strFilter)

If Mid$(strFilter, lngAnt, 1) = "|" Then _

Mid$(strFilter, lngAnt, 1) = Chr$(0)

Next

 

.lpstrFilter = strFilter

.lpstrFile = Space$(254)

.nMaxFile = 255

.lpstrFileTitle = Space$(254)

.nMaxFileTitle = 255

.lpstrInitialDir = strInitDir

.lpstrTitle = strTitel

.flags = OFN_HIDEREADONLY Or OFN_OVERWRITEPROMPT Or _

OFN_CREATEPROMPT

 

lngAnt = GetSaveFileName(lngOpenFileName)

If (lngAnt) Then

ShowSaveDlg = Trim$(.lpstrFile)

Else

ShowSaveDlg = ""

End If

End With

End Function

 

...

..

Private Sub cmdLoad_Click()

sFile = ShowOpenDlg(Me, "Textdateien (*.txt)|*.txt|All Files (*.*)|*.*", "Open Text File...", App.Path)

If (sFile <> "") Then MsgBox "Ausgewählte Datei: " + sFile

..

..

 

End Sub

 

Private Sub cmdSave_Click()

'Speichern...

sFile = ShowSaveDlg(Me, "*.txt (Textdateien)|*.txt", "Save File", App.Path)

If (sFile <> "") Then MsgBox "Gewählter Dateiname: " + sFile

...

End Sub

Link to comment
Der letzte Beitrag zu diesem Thema ist mehr als 180 Tage alt. Bitte erstelle einen neuen Beitrag zu Deiner Anfrage!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...