473,378 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

NumericUpDown and Closing Dialog Box

I am new to VB and need to use it for my school project. As the project is about some booking system, I need to enable users to select the time they want to book the facilities.

I would like to know how can I display the time in a label together in the form of , for example, instead of "9 : 0", I want to have "9 : 00"? I know that the DateTimePicker can easily accomplish what I want but I do not need the time to be precise until seconds.

Another question is that how do I close the main form after I had opened up another form? I had tried adding "Me.Close" after the code "frmExample.ShowDialog()" but it does not execute.

Thanks and sorry if you may find it difficult to understand my English because I do not normally speak or write in English.
Jul 17 '07 #1
6 1870
Dököll
2,364 Expert 2GB
Thanks and sorry if you may find it difficult to understand my English because I do not normally speak or write in English.
Hello, AngZangGui!

Your English is just fine:-)

how can I display the time in a label together in the form of , for example, instead of "9 : 0", I want to have "9 : 00"?
I would say make your label longer, it looks like what you need is 9:00 I will take a good look myself. But there must be a format section in properties that will allow you change a field's date format to what you need.

how do I close the main form after I had opened up another form? I had tried adding "Me.Close" after the code "frmExample.ShowDialog()" but it does not execute.

You started off pretty good, try Me.Close or:

Expand|Select|Wrap|Line Numbers
  1. ...your code here
  2. Unload Me
  3. MyNewForm.Show
  4. End Sub
  5.  
I think that's it, with Unload Me you do not truly need Me.Close. You may find where it is important. MyNewForm is the form name to which you need to make visible. You could have also said:

Expand|Select|Wrap|Line Numbers
  1. ...your code here
  2. MyOldForm.Visible=False
  3. MyNewForm.Visible=True
  4. End Sub
  5.  
Either way your other form would then be visible. Please stay tuned if you need help. Good luck and welcome!
Jul 17 '07 #2
Killer42
8,435 Expert 8TB
I am new to VB and need to use it for my school project. As the project is about some booking system, I need to enable users to select the time they want to book the facilities.

I would like to know how can I display the time in a label together in the form of , for example, instead of "9 : 0", I want to have "9 : 00"? I know that the DateTimePicker can easily accomplish what I want but I do not need the time to be precise until seconds.

Another question is that how do I close the main form after I had opened up another form? I had tried adding "Me.Close" after the code "frmExample.ShowDialog()" but it does not execute.

Thanks and sorry if you may find it difficult to understand my English because I do not normally speak or write in English.
Hi there.

Firstly, I do normally speak and write English, and I would say yours is excellent. Better than what we see from many native speakers.

To place a time value in a label in whatever format you like, I'd suggest you play around with the Format() function. I won't go into detail, because I use VB6 (which is about ten years old) and it looks as though you are using a later version. The syntax details are often different.

As for opening/closing the form, unfortunately I think this is an area which is very different between our versions of VB. But I would ask, are you opening the form as "modal"? You might need to check the documentation for ShowDialog, but I suspect it does so. When you open a "modal" form, it takes control and doesn't return it until you close or hide it. So your Close statement may be executing after your other form has done its thing. You may need to look into an alternative method of opening the form.

Don't forget, I'm not familiar with the later versions of VB, so if what I said doesn't seem to work out, don't assume you're doing something wrong - there's a good chance it's my fault.
Jul 17 '07 #3
Dököll
2,364 Expert 2GB
We must have been posting the same instant, good advice...
Jul 17 '07 #4
Thanks for the all the help and the encouragement. By the way, I'm using vb 2003 because the school lab uses it.

I managed to display the time as "9:00" but the code I used was a little too crude.
Here's what I typed:

Expand|Select|Wrap|Line Numbers
  1. strEndMin = spnEndMin.Text
  2.         If strEndMin < 10 Then
  3.             lblResvEnd.Text = "" & strEndHr & " : 0" & strEndMin
  4.         Else
  5.             lblResvEnd.Text = "" & strEndHr & " : " & strEndMin
  6.         End If
  7.  
As for the dialog box, I set Me.Visible = False before I opened up my new Dialog.

Have a nice day. :)
Jul 17 '07 #5
Dököll
2,364 Expert 2GB
Thanks for the all the help and the encouragement. By the way, I'm using vb 2003 because the school lab uses it.

I managed to display the time as "9:00" but the code I used was a little too crude.
Here's what I typed:

Expand|Select|Wrap|Line Numbers
  1. strEndMin = spnEndMin.Text
  2.         If strEndMin < 10 Then
  3.             lblResvEnd.Text = "" & strEndHr & " : 0" & strEndMin
  4.         Else
  5.             lblResvEnd.Text = "" & strEndHr & " : " & strEndMin
  6.         End If
  7.  
As for the dialog box, I set Me.Visible = False before I opened up my new Dialog.

Have a nice day. :)
Still you're using a better version than I am. Am I to guess that you are okay now, by the way, regarding the above?
Jul 18 '07 #6
Still you're using a better version than I am. Am I to guess that you are okay now, by the way, regarding the above?
Except for the closing of the dialog box, I'm quite fine. I just realised that I never really close the dialog box, merely making it invisible to the user. Perhaps I try something else later when I get home.
Jul 18 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
10
by: Bonj | last post by:
I'm using a number of NumericUpDown controls on my form, which controls printer settings such as number of pages. However I want to override one of the default behaviours of the control, namely...
0
by: Sachin | last post by:
On a form I have two NumericUpDown controls to show "nUdFrom" and "nUdTo" values. I want to add validation code for the same, like value in "nUdFrom" should alway me less than that of in "nUdTo"...
0
by: Koert | last post by:
Hi In the NumericUpDown control I have to detect that Tab was pressed so I have inherited the NumericUpDown and overroden the PreProcessMessage function. In the DateTimePicker (for example) this...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: abc my vclass | last post by:
My win-form have many numericupdown controls to applied. But numericupdown control don't like textbox, text box control can automatic selected text when got focus. Is there any method can let me...
4
by: illegal.prime | last post by:
Hey all, I have a NumericUpDown control on a Panel or potentially a Form that have AutoScroll enabled. When the NumericUpDown is active I would like the Form/Panel/whatever not to scroll when I...
5
by: Len Weltman | last post by:
I am trying to pass a NumericUpDown object into a class method using Visual Studio 2005, but the control type is not found in Intellisense and the type declaration is flagged as an error. Here...
4
by: rdemyan | last post by:
I'm using code from the following web page to open the API Browse Folder dialog http://www.mvps.org/access/api/api0002.htm It all works fine. But if the dialog box is open and the user closes...
2
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello experts, I posted a disturbing question in here:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.