Results 1 to 19 of 19

Thread: [RESOLVED] Form instead of MsgBox

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Location
    vbforums
    Posts
    809

    Resolved [RESOLVED] Form instead of MsgBox

    I want to use form with label instead of messagebox in this code

    Code:
    Private Sub Form_Load()
    On Error Resume Next
    SaveSetting "hh", "StartupForm", "TimesRun", GetSetting("hh", "StartupForm", "TimesRun", 0) + 1
    Timesrun = GetSetting("hh", "StartupForm", "TimesRun")
    MsgBox "You have Used this programme " & Timesrun & " times"
    End Sub

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Form instead of MsgBox

    ok... so what's stopping you? Create your form... slap a label on it, and presumably a button, add some code behind the button to close it when clicked. Then create an instance of your form, set the label caption with your text then show the form. Be sure to use vbModal in the parameters.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Location
    vbforums
    Posts
    809

    Re: Form instead of MsgBox

    Quote Originally Posted by techgnome View Post
    ok... so what's stopping you? Create your form... slap a label on it, and presumably a button, add some code behind the button to close it when clicked. Then create an instance of your form, set the label caption with your text then show the form. Be sure to use vbModal in the parameters.

    -tg
    how can I use this line of code for form and a label
    Code:
    MsgBox "You have Used this programme " & Timesrun & " times"

  4. #4
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Form instead of MsgBox

    try like this
    Code:
    Private Sub Command1_Click()
    Form2.Label1.Caption = "You have Used this programme " & Timesrun & " times"
    Form2.Show vbModal
    End Sub
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Location
    vbforums
    Posts
    809

    Re: Form instead of MsgBox

    Quote Originally Posted by seenu_1st View Post
    try like this
    Code:
    Private Sub Command1_Click()
    Form2.Label1.Caption = "You have Used this programme " & Timesrun & " times"
    Form2.Show vbModal
    End Sub
    in my #1 post .. the code which i have shown saves the instances of a programme .. and i think & Timesrun & " times will not do the task ..

    my aim is whenever the form1 is launched the popup message comes up that how many time the form1 has been launched. so instead of popup message i want to use form2 .

  6. #6
    Lively Member
    Join Date
    Feb 2012
    Posts
    72

    Re: Form instead of MsgBox

    im not sure if you follow but seenu's code is excatly what your looking for
    he placed his code under a click event and im guessing ur looking to load it at startup,
    so just place his code under the form_load event
    when your program starts it will tell it to load form2 at the same time and will also tell it to set the caption for that label

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Location
    vbforums
    Posts
    809

    Re: Form instead of MsgBox

    here I am attaching a sample ..

    in this sample when programme is launched it shows tha count of programme to be use [popup message] .. when we go to form2 and then come back from form2 to form1 .. how to not show the [popup message]
    Attached Files Attached Files

  8. #8
    Lively Member
    Join Date
    Feb 2012
    Posts
    72

    Re: Form instead of MsgBox

    ok this makes no real sense to me at all
    i thought you were looking to make a program what when runs, opens another form to inform the user on how many times they have ran the program?
    if this is the case then i think you need something like this
    Code:
    Private Sub Form_Load()
    On Error Resume Next
    SaveSetting "hh", "StartupForm", "TimesRun", GetSetting("hh", "StartupForm", "TimesRun", 0) + 1
    Timesrun = GetSetting("hh", "StartupForm", "TimesRun")
    Form2.Label1.Caption = "You have used this Programme - " & Timesrun & " Times"
    Form2.Show
    End Sub
    if thats not what your looking to do then you need to explain it a little better

  9. #9

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Location
    vbforums
    Posts
    809

    Re: Form instead of MsgBox

    Quote Originally Posted by Weeluke View Post
    ok this makes no real sense to me at all
    i thought you were looking to make a program what when runs, opens another form to inform the user on how many times they have ran the program?
    if this is the case then i think you need something like this
    Code:
    Private Sub Form_Load()
    On Error Resume Next
    SaveSetting "hh", "StartupForm", "TimesRun", GetSetting("hh", "StartupForm", "TimesRun", 0) + 1
    Timesrun = GetSetting("hh", "StartupForm", "TimesRun")
    Form2.Label1.Caption = "You have used this Programme - " & Timesrun & " Times"
    Form2.Show
    End Sub
    if thats not what your looking to do then you need to explain it a little better
    brother have you read my post #7 .. it is now another issue ..

  10. #10
    Lively Member
    Join Date
    Feb 2012
    Posts
    72

    Re: Form instead of MsgBox

    ohhh ok,
    try replacing this with the code on your form1
    Code:
    Dim booCheck As Boolean
    
    Private Sub Command1_Click()
    Form2.Show
    Unload Me
    End Sub
    
    
    Private Sub Form_Load()
    Form1.Show
    On Error Resume Next
    SaveSetting "hh", "StartupForm", "TimesRun", GetSetting("hh", "StartupForm", "TimesRun", 0) + 1
    Timesrun = GetSetting("hh", "StartupForm", "TimesRun")
    If booCheck = False Then
        MsgBox "You have used this Programme - " & Timesrun & " Times"
        booCheck = True
    Else
        'dont do anything
    End If
    
    End Sub
    basically it makes a boolean variable which is auto set to false
    then once the msgbox has been ran it sets the boolean to true
    the if statement to check if boolean = true then dont show msgbox

    hope this helps, sorry for the confusion

  11. #11
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Form instead of MsgBox

    *facepalm* ....

    I thought I explained how to do this all quite clearly back in post #2...

    if you don't want [popup message] .... then TAKE OUT the call to MsgBox .... you wanted to replace the message box with form2... so that's what you shoudl have done.... use Form2.Show vbModal INSTEAD of MsgBox ... short of writing the code (which has already been done several times over now) and uploading it, I don't know how to be more clearer.

    Meanwhile rather than posting the code so we can take a quick look, you're posting the whole project expecting people to download it, unzip it, extract the files, figure out which file to open, open it up.... too much effort for a simple problem.

    The code in post #8 is what you want... no more, no less...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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

    Re: Form instead of MsgBox

    Try putting the code in the Form_Initialize section. Initialize means to start off usually runs only once throughout a project's execute (one per object) whereas the Form_Load section runs the code each time you load a form.

    Edit:

    vb Code:
    1. Private Sub Form_Initialize()
    2. Form1.Show
    3. On Error Resume Next
    4. SaveSetting "hh", "StartupForm", "TimesRun", GetSetting("hh", "StartupForm", "TimesRun", 0) + 1
    5. Timesrun = GetSetting("hh", "StartupForm", "TimesRun")
    6. popup.Label1.Caption = "You have used this Programme - " & Timesrun & " Times"
    7. popup.Show
    8. End Sub
    Last edited by Nightwalker83; Apr 21st, 2012 at 01:39 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

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Location
    vbforums
    Posts
    809

    Re: Form instead of MsgBox

    Quote Originally Posted by Weeluke View Post
    ohhh ok,
    try replacing this with the code on your form1
    Code:
    Dim booCheck As Boolean
    
    Private Sub Command1_Click()
    Form2.Show
    Unload Me
    End Sub
    
    
    Private Sub Form_Load()
    Form1.Show
    On Error Resume Next
    SaveSetting "hh", "StartupForm", "TimesRun", GetSetting("hh", "StartupForm", "TimesRun", 0) + 1
    Timesrun = GetSetting("hh", "StartupForm", "TimesRun")
    If booCheck = False Then
        MsgBox "You have used this Programme - " & Timesrun & " Times"
        booCheck = True
    Else
        'dont do anything
    End If
    
    End Sub
    basically it makes a boolean variable which is auto set to false
    then once the msgbox has been ran it sets the boolean to true
    the if statement to check if boolean = true then dont show msgbox

    hope this helps, sorry for the confusion
    thanks the code work fine .. but please I have another issue because I thought this code only work for all .. actually I have two popup forms .. popup1 and popup2 .. as I have shown in attached project only one popup form .. whereas there are two .. allthe way I have four forms in a project ..
    form1
    form2
    popupfrm1
    popupfrm2

    at start up three forms are loaded form1 with popupfrm1 and popupfrm2 .. after unloading popupfrm1 and popupfrm2 .. the form1 have command button go to form2 .. and form2 have also command button go to form1 .. when coming back from form2 to form1 .. only one popupfrm1 is not shown whereas popupfrm2 is again popup .. by your code .. please help more

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

    Re: Form instead of MsgBox

    @ janu, have you tried the code I posted?
    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

  15. #15
    Lively Member
    Join Date
    Feb 2012
    Posts
    72

    Re: Form instead of MsgBox

    Lol, so you havent learnt one thing from the code that was given?
    Sure why dont we write the whole project for you?
    I really dont mean to be rude but the problem u are having has the solution in the code!!
    Its like this, im happy to help if a person is stuck but i find it really annoying when people want it handed to them on a plate!
    Please read through the code the solution is in there!
    If you are unable to understand the code then ask what it means, no-one minds helping people to understand!
    sorry for my little rant but this stuff grinds my gears!!
    also try nightwalkers code because its excatly what you need!
    Last edited by Weeluke; Apr 21st, 2012 at 02:43 AM.

  16. #16

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Location
    vbforums
    Posts
    809

    Re: Form instead of MsgBox

    Quote Originally Posted by Weeluke View Post
    Lol, so you havent learnt one thing from the code that was given?
    Sure why dont we write the whole project for you?
    I really dont mean to be rude but the problem u are having has the solution in the code!!
    Its like this, im happy to help if a person is stuck but i find it really annoying when people want it handed to them on a plate!
    Please read through the code the solution is in there!
    If you are unable to understand the code then ask what it means, no-one minds helping people to understand!
    sorry for my little rant but this stuff grinds my gears!!
    also try nightwalkers code because its excatly what you need!
    sorry I was absent minded I placed the request which was solved by Weeluke, actually I have another request ...

    Here I am attaching a sample project .. in which one form is renamed as productupdate .. is it possible if when project is ist time launched on any mechine .. productupdate will open and then in next instance productupdate should not appear .. like project products are updated in ist instance only ... using system memory ...
    Attached Files Attached Files

  17. #17
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Form instead of MsgBox

    check the attached project, hope u need something like this.
    Attached Files Attached Files
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  18. #18

    Thread Starter
    Fanatic Member
    Join Date
    Mar 2009
    Location
    vbforums
    Posts
    809

    Re: Form instead of MsgBox

    Quote Originally Posted by seenu_1st View Post
    check the attached project, hope u need something like this.
    you have done a great job .. you are really great and helping .. rated you best

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

    Re: Form instead of MsgBox

    Quote Originally Posted by janu View Post
    you have done a great job .. you are really great and helping .. rated you best
    You didn't even check my code which as much simpler.
    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

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