Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[VB.NET] Performing an action after a file is found

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Luigi
Grandmaster Cheater Supreme
Reputation: 1

Joined: 24 Mar 2008
Posts: 1082

PostPosted: Wed May 27, 2009 5:02 pm    Post subject: [VB.NET] Performing an action after a file is found Reply with quote

Using an explorer form, I would want the user to locate an item, like blah.txt for example. After they locate it, I want it to perform an action that I specify. How would I perform this action?
Back to top
View user's profile Send private message
shhac
Expert Cheater
Reputation: 0

Joined: 30 Oct 2007
Posts: 108

PostPosted: Wed May 27, 2009 5:41 pm    Post subject: Reply with quote

Add an open file dialogue (I'll call this OpenFileDialog1).
Add a button (I'll call this Button1).
Button1 Click:
Code:
OpenFileDialog1.ShowDialog()

OpenFileDialog1 FileOk:
Code:
Dim file As String = OpenFileDialog1.FileName
If Not System.IO.File.Exists(file) Then
    MsgBox("404")
Else
    'Continue here
End If
Back to top
View user's profile Send private message
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Wed May 27, 2009 11:08 pm    Post subject: Reply with quote

Don't create another event handler.

In the event handler that you want to open the dialog put:

Code:
Dim openFileDialog1 As System.Windows.Forms.OpenFileDialog

        openFileDialog1 = New System.Windows.Forms.OpenFileDialog()

        If openFileDialog1.ShowDialog() = DialogResult.OK Then
            'Code here
        End If

_________________


Last edited by yoyonerd on Thu May 28, 2009 10:38 am; edited 1 time in total
Back to top
View user's profile Send private message AIM Address
shhac
Expert Cheater
Reputation: 0

Joined: 30 Oct 2007
Posts: 108

PostPosted: Thu May 28, 2009 6:48 am    Post subject: Reply with quote

Doesn't doing that mean the programme will hang whilst the dialogue is open?
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Thu May 28, 2009 7:11 am    Post subject: Reply with quote

shhac wrote:
Doesn't doing that mean the programme will hang whilst the dialogue is open?

No, it works. The declaration seems odd tho. Maby it is something vbish.
I would have solved it quite similar :

Code:
1: Dim ofd As New OpenFileDialog()
2: ofd.Filter = "|*.*"
3: If ofd.ShowDialog() = DialogResult.OK Then
4:     MessageBox.Show("You have selected the follow file " + ofd.FileName)
5: End If
6:
7:
8: '=======================================================
9: 'Service provided by Telerik (www.telerik.com)
10: 'Conversion powered by NRefactory.
11: 'Built and maintained by Todd Anglin and Telerik
12: '=======================================================

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
yoyonerd
Grandmaster Cheater
Reputation: 0

Joined: 26 Apr 2008
Posts: 699
Location: -->formerly yoyonerd<--

PostPosted: Thu May 28, 2009 10:39 am    Post subject: Reply with quote

Lol, oops, I left traces of the filter in my code.

I never use VB >.> I had to try translating it from C#

_________________
Back to top
View user's profile Send private message AIM Address
shhac
Expert Cheater
Reputation: 0

Joined: 30 Oct 2007
Posts: 108

PostPosted: Thu May 28, 2009 11:43 am    Post subject: Reply with quote

I basically never do
New OpenFileDialog()
I just use VS and add one to my project. (only need one, can just change the filters etc if necessary)
Back to top
View user's profile Send private message
NINTENDO
Grandmaster Cheater Supreme
Reputation: 0

Joined: 02 Nov 2007
Posts: 1371

PostPosted: Thu May 28, 2009 3:44 pm    Post subject: answered? Reply with quote

did all this answer your question, Weibchen?

a little bit more advanced solution would be to work with tree- and listviews. But thats out of range in this case i gues. Just wanted to bring it up tho so that you know.

_________________
Intel over amd yes.
Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger MSN Messenger
hehewaffles
How do I cheat?
Reputation: 0

Joined: 23 Apr 2009
Posts: 5

PostPosted: Thu May 28, 2009 5:48 pm    Post subject: Reply with quote

shhac wrote:
I basically never do
New OpenFileDialog()
I just use VS and add one to my project. (only need one, can just change the filters etc if necessary)


But if you're like me, then you don't like cluttering up your designer window with that annoying bar at the bottom--especially when it's a large form. Why waste the space when you can just type it?
Back to top
View user's profile Send private message
shhac
Expert Cheater
Reputation: 0

Joined: 30 Oct 2007
Posts: 108

PostPosted: Thu May 28, 2009 8:15 pm    Post subject: Reply with quote

hehewaffles wrote:
shhac wrote:
I basically never do
New OpenFileDialog()
I just use VS and add one to my project. (only need one, can just change the filters etc if necessary)


But if you're like me, then you don't like cluttering up your designer window with that annoying bar at the bottom--especially when it's a large form. Why waste the space when you can just type it?
About most things I would agree about not liking clutter; but in this case I'm pretty sure its better memory usage to not keep creating/destroying these dialogues.
When was the last time you needed a screen-sized form?
Back to top
View user's profile Send private message
hehewaffles
How do I cheat?
Reputation: 0

Joined: 23 Apr 2009
Posts: 5

PostPosted: Thu May 28, 2009 8:34 pm    Post subject: Reply with quote

shhac wrote:
hehewaffles wrote:
shhac wrote:
I basically never do
New OpenFileDialog()
I just use VS and add one to my project. (only need one, can just change the filters etc if necessary)


But if you're like me, then you don't like cluttering up your designer window with that annoying bar at the bottom--especially when it's a large form. Why waste the space when you can just type it?
About most things I would agree about not liking clutter; but in this case I'm pretty sure its better memory usage to not keep creating/destroying these dialogues.
When was the last time you needed a screen-sized form?


Right now, and my previous project, haha.

I doubt it really matters, though if it bugs you, I'd just keep a static variable, rather than having your form instantiate it for you, which is basically what it's doing behind the scenes.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites