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

InputBox

In an InputBox I want to get numeric data. This works wel until u use the
decimal seperator on the numeric keyboard. In the country settings the
decimal seperator is set to a , In all apps this is recognised but in the
inputbox a . (dot) is recognised. In my VBA app the dot is ignored so
instead of getting 1,5 (for instance) you get 15.

Dus anyone know a way to avoid this?
Is there another way to get interactive formatted input within a module??

Thanxx for your help
Nov 12 '05 #1
2 11244
"Joop" <ja****@exc.nl> wrote in
news:bj**********@news.hccnet.nl:
In an InputBox I want to get numeric data. This works wel
until u use the decimal seperator on the numeric keyboard. In
the country settings the decimal seperator is set to a , In
all apps this is recognised but in the inputbox a . (dot) is
recognised. In my VBA app the dot is ignored so instead of
getting 1,5 (for instance) you get 15.

Dus anyone know a way to avoid this?
Is there another way to get interactive formatted input within
a module??

Thanxx for your help

Two options: 1) replace the messagebox with a form.
2) modify your VBA code (this could be as simple as
adding a line that changes the period to a comma).

Bob

Nov 12 '05 #2
The best solution would be to make a small form and use that in place of
place of the input box. You can actually design a form that looks identical
to the input box, but is only a form. (just turn off all the junk like
navigation buttons etc.). The end result is that you can use a text box.

The trick you need is how do you wrap a form into a function?

The soltion is as follows:

Of course, if code opens a form, it does NOT wait, the calling code
continues to run. Thus, what we need is the call code (the docmd.Openform)
to halt, and wait while the user enters some value from the prompt form.
When done, then your calling code can examine the form' values.

Ok, here is how you do it. You open the form in acDialog mode. This will
halt the calling code, and wait. The user then enters some data into fields,
and the hits the ok button. The trick here is that the ok button DOES NOT
close the form, but sets the forms visible property to false. The will cause
the form to drop out of acDialog mode, and then the calling code will
continue!. If the user does in fact hit cancel, or closes the form, you
consider that as a CANCEL!! (ie: the cancel, or even the "X" in the upper
right corner is thus considered a close/cancel).

Hence, the code looks as

' lets open a prompt form
strF = "frmGetComboName"
docmd.OpenForm strF,acNormal,,,,acDialog

' the above code opens our form "frmGetComboName", and the waits until the
user
enters some data, and then hits ok. The code behind the ok button in the
GetName form does NOT close the form, but does

me.Visiable = false

' at this point, either the user hit ok, or closed the form. If the form is
still open, then user did not cancel, and we assume he hit OK

if isloaded(strF) = true then
' code goes here to example values
strName = forms(strF)!ThenameField
strSex = fomrs(strF)!GenderField
' ok, got our data...lets close the form
docmd.Close acForm,strF
else
' if the form is not open, then user hit the "x", or the cancel
' button on the GetName form. Note that the cancel button on
' the GetName from simply does a docmd.close

msgbox "user canceled"
end if

You also need the code for isloaded. It can be found in tons of examples,
and also in the northwind traders. It is reproduced below just in case
you don't have it:

You can also thus wrap the whole acDialog form code in a function that
returns a value if you want. (I do this for date calendar prompts, and
you thus get re-usable form that can be used anywhere by a simple function).

You could create a function called MyInput
Function fIsLoaded(ByVal strFormName As String) As Integer
'Returns a 0 if form is not open or a -1 if Open
If SysCmd(acSysCmdGetObjectState, acForm, strFormName) <> 0 Then
If Forms(strFormName).CurrentView <> 0 Then
fIsLoaded = True
End If
End If
End Function

Just remember, that logically you consider that if the form gets closed via
the X, or by the user's cancel button, the form is NOT loaded.
--
Albert D. Kallal (MVP)
Edmonton, Alberta Canada
ka****@msn.com
http://www.attcanada.net/~kallal.msn
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: news.microsoft.com | last post by:
hey all, I am having an odd problem with the InputBox in VB.NET, and it ONLY happens on one of my computers. When I try "Dim x as String = InputBox("TESTPROMPT"), I get the following error: ...
2
by: missimaths | last post by:
I was wondering if anyone knew of a way to control the text a user types into an inputbox? I want the user to type in four letters only. I can check the lenght by using the len() function in vba...
1
by: Hans Kamp | last post by:
How do I use InputBox? private void addButton_Click(object sender, System.EventArgs e) { string newName; newName = InputBox("t1", "t2", "t3"); namesListBox.Items.Add(newName); }
1
by: | last post by:
When trying to use the InputBox function I get the error "InputBox is a namespace and therefore is not a valid expression". Can anyone tell me what the problem is? Thanks.
7
by: portroe | last post by:
How can you populate an array using an inputbox(es)? thanks portroe
3
by: jcrouse | last post by:
Here is my code: Private Sub cmP1JoyUpLabelSize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmP1JoyUpLabelSize.Click lblP1JoyUp.Width = InputBox("Enter the Width of...
8
by: about:mozilla | last post by:
I'm just a newbie in vb.net and I have this terrible problem. I want to use inputbox to get number. -User can give numbers starting from 0 -If cancel is pressed then default number stays -If text...
2
by: MLH | last post by:
HowManyMore = InputBox(MyString, "How Many More?", "3") The above line results in an InputBox displaying that has an X button in the upper right corner. And next to it, there's a ? button (for...
8
by: jpoquette | last post by:
I have recently upgraded a Visual Basic 2003 win forms application to 2005. After doing so I can no longer get my project to compile. The code is bombing on any line that uses an InputBox. I'm...
0
by: insight_find | last post by:
I would like to check the user input into an inputbox in vb.net 2003. The inputbox in my program assigns the input from the inputbox into an array called get_grades which takes in students grades...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.