473,387 Members | 1,603 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,387 software developers and data experts.

Simple question - data format

274 100+
When a user hit enter key to go to UnitCost field, price is selected to let user change default price it if he want.IF he press enter he moves to next field without changing it.
Problem is, if price is highlighted e.g 0.010 and user tries to enter .10 it doed not accept the decimal in the beginning. However 0.10 is accepted. The only case a decimal is allowed to enter as first position, is when user clears the existing entry.

I want to allow decimal at first position without clearing.
Please help it is urgent.

Here is my code

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtUnitCost_GotFocus()
  2.     txtUnitCost.SelStart = 0
  3.     txtUnitCost.SelLength = Len(txtUnitCost)
  4. End Sub
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtUnitCost_KeyPress(KeyAscii As Integer)
  2.  
  3. 'Validation check
  4. ' Allows only numeric enteries in the code field discard other characters
  5.  
  6.     Select Case KeyAscii
  7.  
  8.         Case Asc(0) To Asc(9)
  9.         Case Str("8")
  10.         Case 46
  11.             Dim position1 As Integer
  12.             position1 = InStr(txtUnitCost.Text, ".")
  13.             If position1 <> 0 And KeyAscii = 46 Then
  14.             KeyAscii = 0
  15.             position1 = 0
  16.             End If
  17.        Case Else
  18.             KeyAscii = 0
  19.        End Select
  20.  
  21. End Sub
Thanks
Jul 14 '09 #1
2 1442
creative1
274 100+
IT is Vb6 question. Isn't it right spot to post this question. I am wonderinf if it is not possible to over right highlighted text with "." decimal?
Jul 15 '09 #2
smartchap
236 100+
Dear creative

replace following line :

Expand|Select|Wrap|Line Numbers
  1. 'If position1 <> 0 And KeyAscii = 46 Then
  2.  
with

Expand|Select|Wrap|Line Numbers
  1. If txtUnitCost.SelLength = Len(txtUnitCost) And KeyAscii = 46 Then
  2. ElseIf position1 <> 0 And KeyAscii = 46 Then
  3.  
Jul 16 '09 #3

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

Similar topics

38
by: jrlen balane | last post by:
basically what the code does is transmit data to a hardware and then receive data that the hardware will transmit. import serial import string import time from struct import * ser =...
3
by: Fabrice Cavarretta | last post by:
I am using a specialized database software (for bibliography: EndNote) that does export in XML. I would like to be able to read that into a simple software, like Excel or Access, in order to do...
6
by: KevinD | last post by:
assumption: I am new to C and old to COBOL I have been reading a lot (self teaching) but something is not sinking in with respect to reading a simple file - one record at a time. Using C, I am...
18
by: Q. John Chen | last post by:
I have Vidation Controls First One: Simple exluce certain special characters: say no a or b or c in the string: * Second One: I required date be entered in "MM/DD/YYYY" format: //+4 How...
10
by: serge calderara | last post by:
Dear all, I need to build a web application which will contains articles (long or short) I was wondering on what is the correct way to retrive those article on web page. In orther words, when...
1
by: Farouche | last post by:
Hi all I have made two simple methods to serialize/deserialize a simple data structure to my database using SoapFormatting. This actually works just great, when the structures stays the same....
1
by: Brian Henry | last post by:
Hello, I was tring to learn socket's (being i never used them before) and have a simple question. I want to create a listner that will get any data recieved and print it out. I've been able to...
6
by: Arne Beruldsen | last post by:
I have a very simple Access data base. No new info is going to be added...the only changes are to existing fields. I have 2 tables both with one row each. I'm using vb.net. I can easily...
5
by: Chelong | last post by:
hey,the follow is the text file content ========================================apple====pear== one Lily 7 0 0 7 7 two Lily 20 20 6.6666 20 8 one Lily 0 10 2.85 4 0 two Lily 22 22 7.33326 2 5 ...
2
by: Dragan | last post by:
Hi, We're working in VS 2005, Team edition, if it makes any difference at all (should be up-to-date and all that, but could not guarantee it is 100%). We've implemented a simple generic wrapper...
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: 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$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.