Results 1 to 15 of 15

Thread: need something important .clent sided

  1. #1

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Unhappy need something important .clent sided

    i am currently working on my client , but how ever i will like to talk about fresh project so nobody get confuse.

    my goal

    1: command1_click create appath xxx.txt that should contain date and time when the exe should be usable , tampering pc time etc should not allow exe to open .


    2: simle example request to know how to lock exe by date , plz i know you gona say do from server but i request to do like this because i want to please thanks.

    please its very important to me 1 example test project please guys

    like have a project with 2 command button
    text1 is date and time


    and command1 execute text1 date and time + close exe not open till date is over
    and the xxxxx.txt in appath showing date and time , this i will t.c of make it hidden etc
    datamiser ,jim,doogleriderboucher

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,181

    Re: need something important .clent sided

    What you ask is very simple... do you know how to read and write files?

  3. #3

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: need something important .clent sided

    yes data i know how to read and write whats next am listening
    but a small example will help thanks so i can se how it works

  4. #4
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,181

    Re: need something important .clent sided

    Well you can't really lock an exe but you can write some code that will read a file and check a value within and abort if the value is unexpected.

    A hint would be that you should use a module with a Sub Main as your start up procedure in which you would read and compare the file value then load your form only if it meets your criteria. You could write to the file there as well if desired.

    If you know how to read and write files already then there is not much of an example required assuming you also know how to use an If statement that is all you would need.

  5. #5

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: need something important .clent sided

    how do i do the module part , that i dont no ? sounds interesting

  6. #6
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: need something important .clent sided

    I'm confused! Do you want your program to check if the date in the text file is correct if not close the program?
    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

  7. #7
    Member
    Join Date
    Apr 2010
    Location
    Gold Coast, Australia
    Posts
    43

    Re: need something important .clent sided

    You already know how to read and write to a file so i'll break it down into some steps for you to work out.

    1. Make your program save the date that you want the program to run in a text file (or create the file yourself)
    2. In your Form_Load section, put Form1.Hide for starters, then make your program read from the file you created in step 1
    3. Compare the date that was read from the text file with today's date
    4. If today's date hasn't passed the date from file just End your application, otherwise Form1.Show and then your application will run from there

    All you would have to do then is make your program load on startup, so to make sense of it what's happening is your program is loading every day hidden, quickly checking the date if it is allowed to be run or not, if it isn't ready then it will just close and all this will be hidden to the user. Then when the date comes you want the program to run, it will show up.

    On newer versions of windows there is a "Startup" folder that you can drag applications into and it will automatically load them every day without having to do any extra code in your program, otherwise just google "vb6 load on startup" or search the forums and you will find something.

    Koushi

  8. #8

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: need something important .clent sided

    nightwalker exactly as u explained thats what i want?????

  9. #9
    Member
    Join Date
    Apr 2010
    Location
    Gold Coast, Australia
    Posts
    43

    Re: need something important .clent sided

    Here ladoo this is my example in code.

    All you have to do is make a txt file in the same location as your programs exe file and call it "LoadDate.txt" write the date you want your program to open in that file and then put this code in your form main:

    Code:
    Private Sub Form_Load()
        Dim NumOfDays As Long
        Dim sFileText As String
        Dim iFileNo As Integer
        
        Form1.Hide
        iFileNo = FreeFile
        
        Open App.Path & "\LoadDate.txt" For Input As #iFileNo
        Input #iFileNo, sFileText
        Close #iFileNo
        
        NumOfDays = DateDiff("d", Date, sFileText)
        
        If NumOfDays <= 0 Then
            Form1.Show
        Else
            End
        End If
    End Sub

  10. #10
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: need something important .clent sided

    Quote Originally Posted by koushi View Post
    Code:
            End
    You should use

    vb Code:
    1. unload me

    or

    vb Code:
    1. Dim objForm As Form
    2.   'unload all forms
    3.   For Each objForm In Forms
    4.     Unload objForm
    5.       Set objForm = Nothing
    6.   Next objForm

    instead.
    Last edited by Nightwalker83; Jan 15th, 2013 at 03:53 AM. Reason: Adding more!
    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

  11. #11
    Member
    Join Date
    Apr 2010
    Location
    Gold Coast, Australia
    Posts
    43

    Re: need something important .clent sided

    Hi Nightwalker83,

    I'm curious now, I have always used "End" if i wanted to completely end my program (as in the example above) as I thought it did close all forms attached to the project. Just quickly tested and confirmed this but is your way better? Would you be able to explain why?

    Also in your For Each loop I think you need an extra statement to check if it isn't the form that is running that loop otherwise if it only gets halfway through closing the forms and it unloads itself then there will still be forms in memory, so would you use something like this?

    Code:
    Dim tmpForm As Form
    
        For Each tmpForm In Forms
            If tmpForm.Name <> Me.Name Then
                Unload tmpForm
                Set tmpForm = Nothing
            End If
        Next
    
        Unload Me
    Last edited by koushi; Jan 15th, 2013 at 04:11 AM.

  12. #12

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: need something important .clent sided

    wow thanks allot guys awsome , the date formate in notepad how should i enter it

  13. #13
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: need something important .clent sided

    Quote Originally Posted by koushi View Post
    Hi Nightwalker83,

    I'm curious now, I have always used "End" if i wanted to completely end my program (as in the example above) as I thought it did close all forms attached to the project. Just quickly tested and confirmed this but is your way better? Would you be able to explain why? thanks
    Read Classic VB - Why is using the 'End' statement (or VB's "stop" button) a bad idea?.
    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

  14. #14
    Member
    Join Date
    Apr 2010
    Location
    Gold Coast, Australia
    Posts
    43

    Re: need something important .clent sided

    Thanks very much, makes a lot of sense!

  15. #15
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,181

    Re: need something important .clent sided

    To use the module approach.
    Add a module to to project. You do this the same way as you would add a form just choose module from the list of options when given.
    Create a sub in the module named sub main

    In this sub main you could add code very much like what was shown in post #9 minus the Form1.Hide and the End statement

    Code:
    Private Sub Main()
        Dim NumOfDays As Long
        Dim sFileText As String
        Dim iFileNo As Integer
        
        iFileNo = FreeFile
        
        Open App.Path & "\LoadDate.txt" For Input As #iFileNo
        Input #iFileNo, sFileText
        Close #iFileNo
        
        NumOfDays = DateDiff("d", Date, sFileText)
        
        If NumOfDays <= 0 Then
            Form1.Show    
        End If
    End Sub
    Under the project menu set the startup object to sub main
    Your form will never be loaded unless the If test is true. If not then the program will just exit without ever loading the form.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width