|
-
May 21st, 2013, 12:28 AM
#1
Thread Starter
Banned
drag drop to list , re question / help
seen other example most staff shown before , how ever i have a text file with these strings inside
james
billy
tony
montana
i want to drag txt file to list and then have it populated is it possible.
-
May 21st, 2013, 01:48 AM
#2
Re: drag drop to list , re question / help
 Originally Posted by ladoo
i want to drag txt file to list and then have it populated is it possible. 
The codes posted in your previous thread can do just that. You only have to modify them a bit.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
May 21st, 2013, 02:07 AM
#3
Thread Starter
Banned
Re: drag drop to list , re question / help
can u help dear
-
May 21st, 2013, 05:41 AM
#4
Re: drag drop to list , re question / help
Just modify the code Bonnie gave you in the other thread so it includes
vb Code:
Dim FF As Integer Public Sub Drag_n_Drop(ByVal hDrop As Long) Dim i As Long, sngLongestText As Single, TW As Single, sBuffer As String, text As String With List1 i = DragQueryFileW(hDrop, &HFFFFFFFF) If i Then .Visible = False .Clear For i = 0& To i - 1& SysReAllocStringLen VarPtr(sBuffer), , DragQueryFileW(hDrop, i) DragQueryFileW hDrop, i, StrPtr(sBuffer), Len(sBuffer) + 1& Open sBuffer For Input As #FF Input #FF, sBuffer .AddItem sBuffer Close #FF TW = TextWidth(sBuffer) If sngLongestText < TW Then sngLongestText = TW Next .Visible = True SendMessageW .hWnd, LB_SETHORIZONTALEXTENT, RIGHT_MARGIN + sngLongestText, 0& End If DragFinish hDrop End With End Sub Private Sub Form_Load() FF = FreeFile ScaleMode = vbPixels DragAcceptFiles hWnd, 1& 'fAccept:=TRUE Subclass Me End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
May 21st, 2013, 08:26 AM
#5
Re: drag drop to list , re question / help
@ Nightwalker
I think ladoo wants to list all the contents of a single dragged text file. If so, then the following are the modifications required:
Code:
Public Sub Drag_n_Drop(ByVal hDrop As Long)
Const RIGHT_MARGIN = 5& 'Right margin for List1's longest item (in pixels)
Dim FN As Integer, sngLongestText As Single, TW As Single, sText As String
With List1
If DragQueryFileW(hDrop, &HFFFFFFFF) Then
.Visible = False
.Clear
SysReAllocStringLen VarPtr(sText), , DragQueryFileW(hDrop, 0&)
DragQueryFileW hDrop, 0&, StrPtr(sText), Len(sText) + 1&
FN = FreeFile
On Error GoTo 1
Open sText For Input Access Read As FN
On Error GoTo 0
Do Until EOF(FN)
Line Input #FN, sText
If LenB(sText) Then
.AddItem sText
TW = TextWidth(sText)
If sngLongestText < TW Then sngLongestText = TW
End If
Loop
1 Close FN
.Visible = True
SendMessageW .hWnd, LB_SETHORIZONTALEXTENT, RIGHT_MARGIN + sngLongestText, 0&
End If
DragFinish hDrop
End With
End Sub
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
May 21st, 2013, 09:52 AM
#6
Thread Starter
Banned
Re: drag drop to list , re question / help
Code:
Const RIGHT_MARGIN = 5& 'Right margin for List1's longest item (in pixels)
Dim FN As Integer, sngLongestText As Single, TW As Single, sText As String
With List1
If DragQueryFileW(hDrop, &HFFFFFFFF) Then
.Visible = False
.Clear
SysReAllocStringLen VarPtr(sText), , DragQueryFileW(hDrop, 0&)
DragQueryFileW hDrop, 0&, StrPtr(sText), Len(sText) + 1&
FN = FreeFile
On Error GoTo 1
Open sText For Input Access Read As FN
On Error GoTo 0
Do Until EOF(FN)
Line Input #FN, sText
If LenB(sText) Then
.AddItem sText
TW = TextWidth(sText)
If sngLongestText < TW Then sngLongestText = TW
End If
Loop
1 Close FN
.Visible = True
SendMessageW .hWnd, LB_SETHORIZONTALEXTENT, RIGHT_MARGIN + sngLongestText, 0&
End If
DragFinish hDrop
End With
stext variable not defind
fn variable not defind
-
May 21st, 2013, 10:03 AM
#7
Re: drag drop to list , re question / help
 Originally Posted by ladoo
stext variable not defind
fn variable not defind
Code:
Dim FN As Integer, sngLongestText As Single, TW As Single, sText As String
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
May 21st, 2013, 06:40 PM
#8
Re: drag drop to list , re question / help
 Originally Posted by Bonnie West
@ Nightwalker
I think ladoo wants to list all the contents of a single dragged text file. If so, then the following are the modifications required:
I should have realized that! I always stop after the first line, etc rather than doing the whole thing when I suppose ought to.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
May 21st, 2013, 09:00 PM
#9
Thread Starter
Banned
Re: drag drop to list , re question / help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|