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

inputbox

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 is given then messagebox gives error

Thanks in advance...

Newbie
Nov 21 '05 #1
8 6037

"about:mozilla" <ab***@mozilla.com> wrote in message
news:cu**********@phys-news1.kolumbus.fi...
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 is given then messagebox gives error

Thanks in advance...


As a newbie you should get a book and learn basics of VB.NET.

My suggestion is "Murach's Beginning Visual Basic.NET"
Nov 21 '05 #2
"about:mozilla" <ab***@mozilla.com> schrieb:
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 is given then messagebox gives error


The 'InputBox' is pretty limited in its functionality. It's currently
impossible to decide whether the user clicked the "Cancel" button or not.
As you say, input cannot be limited to a certain format too. If you want a
good user experience, implement a form that replaces 'InputBox' and provides
the additional functionality.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #3
Dim sNumber As String
Dim iNumber As Integer

sNumber = InputBox("Enter a number", "Numbers Only", "0")

If IsNumeric(sNumber) Then
iNumber = CInt(sNumber)
Else
If sNumber <> "" Then 'Cancel returns an empty string
MessageBox.Show("Enter numeric values only", "Numbers Only",
MessageBoxButtons.OK, MessageBoxIcon.Warning)
End If
End If
"about:mozilla" wrote:
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 is given then messagebox gives error

Thanks in advance...

Newbie

Nov 21 '05 #4
"ocertain" <oc******@discussions.microsoft.com> schrieb:
Dim sNumber As String
Dim iNumber As Integer

sNumber = InputBox("Enter a number", "Numbers Only", "0")

If IsNumeric(sNumber) Then
iNumber = CInt(sNumber)


This won't work in all cases too. See (complete discussion):

<URL:http://groups.google.de/groups?threadm=41c9a159%240%247835%24ba620e4c%40ne ws.skynet.be>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
No, but it does what was asked and gives him something to play around with.

"Herfried K. Wagner [MVP]" wrote:
"ocertain" <oc******@discussions.microsoft.com> schrieb:
Dim sNumber As String
Dim iNumber As Integer

sNumber = InputBox("Enter a number", "Numbers Only", "0")

If IsNumeric(sNumber) Then
iNumber = CInt(sNumber)


This won't work in all cases too. See (complete discussion):

<URL:http://groups.google.de/groups?threadm=41c9a159%240%247835%24ba620e4c%40ne ws.skynet.be>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #6
After all, he was asking for some pretty fundamental functionality. The
snippet I provided has everything for which he had asked. I didn't state that
it was the "end all" of input routines. The InputBox may have limitations
but it is still useful for simple data input.

"ocertain" wrote:
No, but it does what was asked and gives him something to play around with.

"Herfried K. Wagner [MVP]" wrote:
"ocertain" <oc******@discussions.microsoft.com> schrieb:
Dim sNumber As String
Dim iNumber As Integer

sNumber = InputBox("Enter a number", "Numbers Only", "0")

If IsNumeric(sNumber) Then
iNumber = CInt(sNumber)


This won't work in all cases too. See (complete discussion):

<URL:http://groups.google.de/groups?threadm=41c9a159%240%247835%24ba620e4c%40ne ws.skynet.be>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #7
"ocertain" <oc******@discussions.microsoft.com> schrieb:
After all, he was asking for some pretty fundamental functionality. The
snippet I provided has everything for which he had asked. I didn't state
that
it was the "end all" of input routines. The InputBox may have
limitations
but it is still useful for simple data input.


I fully agree. The intention of my post was to make the OP aware of
possible limitations of the approach you posted.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #8
And - as I stated - the snippet will work for the purposes the OP
established. The method you proposed may be a bit much for a beginner. Using
VB's built in objects like InputBox is a good way for a begginer to get his
feet wet. It's best to learn to walk before one attempts to runs.

"Herfried K. Wagner [MVP]" wrote:
"ocertain" <oc******@discussions.microsoft.com> schrieb:
After all, he was asking for some pretty fundamental functionality. The
snippet I provided has everything for which he had asked. I didn't state
that
it was the "end all" of input routines. The InputBox may have
limitations
but it is still useful for simple data input.


I fully agree. The intention of my post was to make the OP aware of
possible limitations of the approach you posted.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #9

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...
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...
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
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: 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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.