Toon posts:

[access + VB]

Pagina: 1
Acties:

Verwijderd

Topicstarter
hallo,
ik ben bezig met een script dat bestanden naar een nieuwe directory copieerd. de gebruiker selecteerd het bestand en het script upload het naar een standaard locatie. jammer genoeg krijg ik het niet voor elkaar om het script mijn source directory uit mijn textbox te laten lezen. handmatig een directory invullen werkt wel.

mijn script:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 Private Type SHFILEOPSTRUCT
    hWnd As Long
    wFunc As Long
    pFrom As String
    pTo As String
    fFlags As Integer
    fAnyOperationsAborted As Boolean
    hNameMappings As Long
    lpszProgressTitle As String
End Type

Private Declare Function SHFileOperation Lib "shell32.dll" Alias "SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long

Private Const FO_COPY = &H2
Private Const FOF_ALLOWUNDO = &H40
Public Sub SHCopyFile(ByVal from_file As String, ByVal to_file As String)
Dim sh_op As SHFILEOPSTRUCT

    With sh_op
        .hWnd = 0
        .wFunc = FO_COPY
        .pFrom = from_file & vbNullChar & vbNullChar
        .pTo = to_file & vbNullChar & vbNullChar
        .fFlags = FOF_ALLOWUNDO
    End With

    SHFileOperation sh_op
End Sub
Private Sub cmdcopy_Click()
SHCopyFile txtFrom.Text, txtTo.Text
End Sub

Private Sub Form_Load()
Dim file_path As String

    file_path = "c:\"
    If Right$(file_path, 1) <> "\" Then file_path = file_path & "\"

    txtFrom.Text = file_path & "TestFrom.txt"
    txtTo.Text = file_path & "TestTo.txt"
End Sub


als ik SHCopyFile txtFrom.Text, txtTo.Text aanpas naar SHCopyFile "c:\test.txt", "e:\test.txt" werkt het wel. wat doe ik fout?

[ Voor 14% gewijzigd door Verwijderd op 11-01-2006 10:37 . Reden: opmaak ]


  • Boss
  • Registratie: September 1999
  • Laatst online: 20:45

Boss

+1 Overgewaardeerd

En als je de textboxes op het formulier ziet hebben ze ook al de waarde zoals je die bij form_load wilt instellen? Probeer het eens zonder de .text achter alle textboxes.

offtopic:
en kan je je code even tussen [ code ]- tags zetten? Maakt het iets leesbaarder

The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it is an aesthetic experience much like composing poetry or music.


Verwijderd

Topicstarter
Boss schreef op woensdag 11 januari 2006 @ 10:31:
En als je de textboxes op het formulier ziet hebben ze ook al de waarde zoals je die bij form_load wilt instellen? Probeer het eens zonder de .text achter alle textboxes.

offtopic:
en kan je je code even tussen [ code ]- tags zetten? Maakt het iets leesbaarder
.text weghalen hielp inderdaad. hartstikke bedankt!

  • Boss
  • Registratie: September 1999
  • Laatst online: 20:45

Boss

+1 Overgewaardeerd

Nu zou ik alleen willen dat ik je kon uitleggen waarom, maar volgens mij is dit 1 van die dingen in Access die niet helemaal lekker gaan :)

The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it is an aesthetic experience much like composing poetry or music.


  • kenneth
  • Registratie: September 2001
  • Niet online

kenneth

achter de duinen

Text is een property waar je alleen wat mee kan als het veld de focus heeft. Als je .Text weglaat, gebruikt Access de impliciete property .Value, en die is altijd bruikbaar.

Look, runners deal in discomfort. After you get past a certain point, that’s all there really is. There is no finesse here.