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
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.
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"
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 .
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
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]
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
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 ..
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
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...
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.
popup.Label1.Caption = "You have used this Programme - " & Timesrun & " Times"
popup.Show
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
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
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
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.
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 ...
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