|
I am not sure but I don't think you can accomplish this with RaiseEvent. However, you can use the
AsyncCallback class. Check your local help files for more information on how to use this class.
Best of Luck
Forever Developing
|
|
|
|
|
Hi,
Is there a way to add file names from a folder on the hard drive to a list box and only show two types of file extensions ie txt and dat files using vb6.
Thanks
|
|
|
|
|
Here you go.
1) You need to add a referance to the Microsoft Scripting Runtime.
2) Add a Command Button to the form
3) Add a ListBox to the form
4) Have Fun
'///BEGIN CODE///
Private Sub Command1_Click()
Dim fso As New FileSystemObject
Dim fld As Folder
Dim fi As File
Dim I As Long
Set fld = fso.GetFolder("C:\")
For Each fi In fld.Files
If MatchesExtension("txt", fi.Name) Then
List1.AddItem fi.Name
End If
Next
End Sub
'Takes a filename and a file extension to match
'Works in reverse on the file name looking for the last
'period character. Once found the string is then compared to the
'passed in sFileExtension parameter.
Private Function MatchesExtension(sFileExtension As String, sFileName As String) As Boolean
Dim sChar As String
Dim sTemp As String
Dim I As Long
MatchesExtension = False
For I = Len(sFileName) To 1 Step -1
sChar = Mid(sFileName, I, 1)
If sChar = "." Then
If sTemp = sFileExtension Then
MatchesExtension = True
Else
MatchesExtension = False
End If
Exit For
End If
sTemp = sTemp & sChar
Next I
End Function
'///END CODE///'
Forever Developing
|
|
|
|
|
Thank you so much for this code. One question. Does this only wory for txt files or can other extensions be used. The two file extensions i'm trying to display is .cdimage and .dvdimage
I tried changing the "txt" in the code you gave me but it did not work.
Any ideas.
Once again Thank you for the code
|
|
|
|
|
Sorry about that. There is a small bug. I tested it with txt files.
Here is the fix you need to make.
In the MatchesExtension Function change
sTemp = sTemp & sChar
TO
sTemp = sChar & sTemp
if you want to add different/more file types you can do some thing like this in the
commandbutton click event
For Each fi In fld.Files
If MatchesExtension("cdimage", fi.Name) Then
List1.AddItem fi.Name
End If
If MatchesExtension("dvdimage", fi.Name) Then
List1.AddItem fi.Name
End If
'Keep adding file extensions. by duplicating the code above
Next
Forever Developing
|
|
|
|
|
Thank you so much. You the man
I'm wondering if i could ask you one more thing.
I was trying to change your code so that I could get it to do the following.
i need to separate the file name eg 50678.cdimage. so that the 50678 goes into one text box and the .cdimage goes into another text box. would you be able to help on this.
Thanks
|
|
|
|
|
Thank you so much. You the man
I'm wondering if i could ask you one more thing.
I was trying to change your code so that I could get it to do the following.
i need to separate the file name eg 50678.cdimage. so that the 50678 goes into one text box and the .cdimage goes into another text box. would you be able to help on this.
Thanks
|
|
|
|
|
Thank you so much. You the man
I'm wondering if i could ask you one more thing.
I was trying to change your code so that I could get it to do the following.
i need to separate the file name eg 50678.cdimage. so that the 50678 goes into one text box and the .cdimage goes into another text box. would you be able to help on this.
Thanks
|
|
|
|
|
I am not sure what you are asking for here.
You want to enter a file name in a text box and have the name and extension split into to differnet text boxes?
Forever Developing
|
|
|
|
|
You hit the nail on the head. I was trying with your code but with no success. Is this possible. If you could help I would be so greatful. This will make the program i'm working on work perfectly.
|
|
|
|
|
Add a command button.
Name it cmdSplit called split
Add 3 text boxes.
Name the first one txtFileName
Name the second one txtFile
Name the third one txtExtension
Private Sub cmdSplit_Click()
SplitFileNameOnDot (txtFileName.Text)
End Sub
Private Function SplitFileNameOnDot(sFileName As String)
Dim sChar As String
Dim sTemp As String
Dim sName As String
Dim sExtension As String
Dim bGotExtension As Boolean
Dim I As Long
For I = Len(sFileName) To 1 Step -1
sChar = Mid(sFileName, I, 1)
If bGotExtension = False Then
sExtension = sChar & sExtension
Else
sName = sChar & sName
End If
If sChar = "." Then
bGotExtension = True
End If
Next I
txtExtension.Text = sExtension
txtFile.Text = sName
End Function
Forever Developing
|
|
|
|
|
This is absoutly brilliant. My code is now finished. With out the help you gave me I don't know what i would have done. Wish I was a brainy as you.
Thank you so much
|
|
|
|
|
Is there any way that I can use the drag,drop effect for my scrabble game Im developing I want to drag a picture and drop onto a label and then show the picture in the target control that was previously in the sender?? Is there a way been searching for ages for help let me know please.....thanx!!
|
|
|
|
|
Here's how to drag an image back and forth between a couple of picture boxes:
Protected Overrides Sub OnLoad(ByVal e As EventArgs)
PictureBox1.Image = Image.FromFile("MyImage.bmp")
PictureBox1.AllowDrop = True
PictureBox2.AllowDrop = True
End Sub
Private dragSource As PictureBox
Private Sub PictureBox_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) _
Handles PictureBox1.MouseMove, PictureBox2.MouseMove
'Initiate a drag if left mouse button is down
If e.Button = MouseButtons.Left Then
dragSource = CType(sender, PictureBox)
DoDragDrop(CType(sender, PictureBox).Image, DragDropEffects.Move)
End If
End Sub
Private Sub PictureBox_DragEnter(ByVal sender As Object, ByVal e As DragEventArgs) _
Handles PictureBox1.DragEnter, PictureBox2.DragEnter
If (Not dragSource Is Nothing) AndAlso (Not sender Is dragSource) Then
e.Effect = DragDropEffects.Move
End If
End Sub
Private Sub PictureBox_DragDrop(ByVal sender As Object, ByVal e As DragEventArgs) _
Handles PictureBox1.DragDrop, PictureBox2.DragDrop
If (Not dragSource Is Nothing) AndAlso (Not sender Is dragSource) Then
CType(sender, PictureBox).Image = dragSource.Image
dragSource.Image = Nothing
dragSource = Nothing
End If
End Sub
Hope this helps
Tom
|
|
|
|
|
hi all
i am currently working on winforms. i am facing a problem in resizing the window once it has been maximized.
Well i have a form with 2 buttons. one for maximising and the other for restoring the form to its original size/any specified size.
in the click event of the first button.. i set the forms's WindowState to FormWindowStae.Maximized. now when i click the second button i want to change the form size back to its original size before being maximized or to some size.i know i can restore the size of the form by using the restore button in the ControlMenu..i dont want to use it. i want to use the second button to do it. i tried setting new values to the Size property of the Form but is of no use.
can anyone please help me in finding as to how i can change the form's size once it has been maximized through code?
thanks and regards
|
|
|
|
|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.WindowState = FormWindowState.Maximized
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.WindowState = FormWindowState.Normal
End Sub
Or did i miss read the question?
Hope this helps
Tom
P.S. can you delete your duplicate posting please?
|
|
|
|
|
Hi there.
I just finished decrypting a file and its in a buffer i created in memory. The problem i'm having now is that I want to run the process directly from memory and not copy the bytes to a file and run. Its unfortunate that the I can't find any Windows API functions that can do that or maybe there is a combination of functions that can effect that.. I don't know. Please i need help.. and fast. Thanks.
I'm using visual Basic 6 not .NET.
re
|
|
|
|
|
AFAIK, you can't in VB6. In C++, this is easily possible, but not ib VB6. I haven't seen any API that allow you to change the program exection like that.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
So if its not possible in VB6, then what. I can't program in C++. Help me out.
|
|
|
|
|
I hate repeating myself -> It's not possible to do in VB6!
After further consideration, you have a second problem though...
If you decrypted an .EXE file, you can't just jump to the file in memory. It must be read and processed by the Loader in Windows. You used to be able to do this with .COM files because they are "memory image" files. What's in the file is exactly what get loaded into memory. .EXE files are not like this at all. They are segment processed and loaded sections at a time and must be setup in memory before the starting point is jumped to.
There is no API function that will process and load the file from memory, only from a valid .EXE. So, the only solution you have is what you're already doing.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
can anybody be able to help me in creating a interactive voice responce system in vb.net(using modem).
geo
|
|
|
|
|
|
I am using vb6 to develop a client server applications. At installation site there are nearly 50 pcs using the application which is installed on each pc. But when there are changes in the application and a new executable file is prepared I need to install it again on all the pcs. Is there any way by which i can install the executable file on all the pcs instead of physically going to each pc ? or can i share the executable file that resides at a centralized location ? Please help me out
SL Tan
|
|
|
|
|
You could place the Exe on a centeralized location. Like a server. Then map a drive to that folder on each of the PC's. Then update you short cuts to point to the mapped drive. This way when a new exe comes out all you have to do is replace the one exe. Also you will need to install all of the exe's dependancies on the other machines.
NOTE: if the app has per user settings that are saved to a ini file, those settings need to be saved in a unique manner for each user. This can be solved in a number of ways.
Forever Developing
|
|
|
|
|
Hi all,
i am writing an IDE like visual studio .Net. i want to produce the same effect as vs.net provide like when you drag and drop a control on a form it appears and if you want to adjust the location of this control you can use the mouse to drag and drop it to any location. i have successfully done every thinig accept that the selection frame. on my mousedown event when selection frame is drawn it goes behind and hides. i want to take it on top i mean it should not hide behind any control instead it should be the top most element when user is grabbing it and moving her mouse. can any body help in this regard. tested code will be plus for me .
Thnx.
|
|
|
|