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

InputBox function

Private Sub Command4_Click()
Dim i
i = InputBox("Enter a number", "Enter")
If i > 10 Then
MsgBox "Number is less than" + i
End If
End Sub

Hey I want that if the user enters number from 1 to 10 in the textbox(InputBox) msgbox comes on clicking the ok Button that" number is b/w 1 to 10," & else part if the user enters greater than 10, then msgbox shows "Number is greater than 10"

Plz help me out,I m new to the Vb.
Apr 5 '08 #1
3 1409
Maybe this...
'--
Private Sub Command4_Click()
Dim i as Variant
OnTop:
i = InputBox("Enter a number between 1 and 10 ", "Enter")
If Len(i) = 0 Then
Exit Sub
ElseIf i > 10 Then
If MsgBox("Number is greater than 10 ", vbExclamation + vbRetryCancel, "Oops") = vbRetry Then GoTo OnTop
ElseIf i < 1 Then
If MsgBox("Number is less than 1", vbExclamation + vbRetryCancel, "Oops") = vbRetry Then GoTo OnTop
End If
End Sub


Private Sub Command4_Click()
Dim i
i = InputBox("Enter a number", "Enter")
If i > 10 Then
MsgBox "Number is less than" + i
End If
End Sub

Hey I want that if the user enters number from 1 to 10 in the textbox(InputBox) msgbox comes on clicking the ok Button that" number is b/w 1 to 10," & else part if the user enters greater than 10, then msgbox shows "Number is greater than 10"

Plz help me out,I m new to the Vb.
Apr 6 '08 #2
QVeen72
1,445 Expert 1GB
Hi,

Try this :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command4_Click()
  2. Dim i
  3. i = Val(InputBox("Enter a number", "Enter"))
  4. If i>=1 And i <=10 Then
  5.     MsgBox "Number " & i & " is b/w 1 to 10"
  6. ElseIf i > 10 Then
  7.     MsgBox "Number " & i & "  is More than 10 " 
  8. Else
  9.     MsgBox "Not Applicable"
  10. End If
  11. End Sub
  12.  
Regards
Veena
Apr 6 '08 #3
Thx Both of U,i have got it. hey can u pls send me the books of vb,if you have ???
Apr 6 '08 #4

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

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: | 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
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...
10
by: omozali | last post by:
Hi, Access (v 2003) is not recognizing the function InputBox this is my code Private Sub Command0_Click() Dim response As String response = inputbox("Enter your name", "Login") End Sub
1
by: Heidi Godbehere | last post by:
Hi, I was wandering if someone could help me........... I have a memo field on a form, which is disabled. I want to use a command button to edit the field, by using InputBox(), but it will...
8
by: Andrus | last post by:
I need WinForms function which displays promp and asks single field from user, like string res = Util.InputBox( "Enter value" ); How to implement this ? Andrus.
5
by: Hutch | last post by:
How do i get the ****** to appear insted of text when it is an inputbox? and not a box inside a form. here is the code i am using Public Function bDisableBypassKey_Click() 'This allows a...
2
by: Nikita0303 | last post by:
Hi, I wanted to know if the user input thru excel inputbox can be restricted to limited values. I am trying to run some analysis on columns with numeric data. But the column has to be input by the...
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: 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
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...
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...

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.