How to enforce hour format? - vb.net

I am using a textbox in vb.net but the input should be an hour format for example, "13h30".
How can I enfprce this by a user? When he puts the first 2 digits like 13 then automaticly the appl. puts a "h" between? Or is there a better solution?
thx

If you are using WinForms then you could use a masked textbox with a mask of 00h00. This doesn't work too well if they subsequently want to edit the value they have entered though as the rightmost digits are shifted left if you do a backspace. You may be better off making a user control

Related

Automatic decimal places in textbox center of six digits in vb.net

I want to show comma sign center of six digits and have length of textbox 7. for example "123,456" like this.
The MaskedTextBox control would be an easy way to accomplish this.
Replace your TextBox by a MaskedTextBox, and try to set the Mask to something like this:
MaskedTextBox1.Mask = "##0,000"
It should make sure that your trailing zero are always showing.

How to customize a textbox

I want to customize a textbox such that the user will input date as shown in image1 below. Note these points :
Apr not 04 or April or anything else.
The order must be dd/mmm/yyyy. even if their computer system date is set otherwise.
Text to be aligned left. How do i do that textbox in visual basic 2010 ?
I think a MaskedTextBox with a custom format will be the right option for you. So that you can restrict the user to enter digits for month and letters for day and year. you can set the mask like the following:
txtCustomDate.Mask = "00/LLL/0000"
Where 0 stands for integer L for Letter, required. Restricts input to the ASCII letters a-z and A-Z. This mask element is equivalent to [a-zA-Z] in regular expressions.
You may get better format options from here

How can I format a label caption?

Here's what I want to do. I have a caption that changes every time someone uses the app. The caption is a number... and now it appears like a regular number 123456 ... I want to add "," every 3 digits and I really don't know how to do it because the number doesn't have the same number of digits every time... (I want it to be 123,456 instead of 123456 or 1,234,567... and so on). Thanks!
I'm assuming you're setting the caption in code, so you can use VBA's format function to do this:
Me.MyLabel.Caption = Format(MyNum, "#,##0")

masked textbox , use hour format with control of max 24(hours):60(minutes)

I use a masked textbox, and I would control the input, the problem is, I use 1 textbox and the control should on the first 2 digits with a maximum of 24 and the last 2 digits with a maximum of 60. Is there a possibility to program this?
Use the _Validating event of the masked textbox. In that example on MSDN, the extra spaces and ':' were stripped out, and the first two digits were validated against 0-23 and the second two digits were validated against 0-59.

Logic to Correct an Incorrect User Input (VB.Net)

I am looking for logic that converts an incorrect user input to a correct integer input.
For example, a user might mistakenly type in letters within an integer input and the logic changes that input to the correct form(integer).
Any ideas?
If you want only numeric values, you can use a numeric control instead of textbox (NumericUpDown if I remember correctly). Otherwise, you can listen to the OnKeyDown or OnKeyPress event, "see" what's inside the argument (the key typed by the user) and eventually change its input. For instance, I'm in Italy and often users use . or , for decimal separator. So I translate dot to comma while the user types. Also, when a non-number is typed, I set e.Cancel to true so nothing is appended to the text displayed.
For typing errors, a BK tree is often used, in conjunction with Levenshtein Distance. Here is a good explanation on how this is applied.
Why would you correct incorrect input? You would want to prompt the user to re-enter the information correctly and tell them to enter an integer.