Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default A simple inputbox & responding msgbox coding

I sure woul oblige for the simplest piece of code for an inputbox as:

"Enter Your Name"

1. If nothing is entered and OK is pressed:
msgbox("Nothing has been entered. Please RETRY")

2. If Cancel is pressed:
msgbox("You have cancelled the operation")

3. If something is entered and OK is pressed:
msgbox("You are " & Nme)

I have also found that codes do not work similarly enough in respect of the
TYPE of the inputbox to be Text or Cell Reference/Range Based, i.e. for
Type:=2 or Type:=8 any reference for relevant material on net.

Thanx in advance.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default A simple inputbox & responding msgbox coding

Can you explain the issue referring to the example below...

Sub TestInputBox()
Dim varInput As Variant
InputBox:
varInput = Application.InputBox("Enter your name", Type:=2)
If varInput = False Then
MsgBox "You have cancelled the Operation": Exit Sub
ElseIf varInput = "" Then
MsgBox "Nothing has been entered. Please RETRY": GoTo InputBox
Else
MsgBox "You are " & varInput
End If
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"FARAZ QURESHI" wrote:

I sure woul oblige for the simplest piece of code for an inputbox as:

"Enter Your Name"

1. If nothing is entered and OK is pressed:
msgbox("Nothing has been entered. Please RETRY")

2. If Cancel is pressed:
msgbox("You have cancelled the operation")

3. If something is entered and OK is pressed:
msgbox("You are " & Nme)

I have also found that codes do not work similarly enough in respect of the
TYPE of the inputbox to be Text or Cell Reference/Range Based, i.e. for
Type:=2 or Type:=8 any reference for relevant material on net.

Thanx in advance.

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 553
Default A simple inputbox & responding msgbox coding

Thanx Jacob,

I don't understand why my previous reply didn't appear, however, would only
a Variant Data Type be used even when a String is expected as an input?

"Jacob Skaria" wrote:

Can you explain the issue referring to the example below...

Sub TestInputBox()
Dim varInput As Variant
InputBox:
varInput = Application.InputBox("Enter your name", Type:=2)
If varInput = False Then
MsgBox "You have cancelled the Operation": Exit Sub
ElseIf varInput = "" Then
MsgBox "Nothing has been entered. Please RETRY": GoTo InputBox
Else
MsgBox "You are " & varInput
End If
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"FARAZ QURESHI" wrote:

I sure woul oblige for the simplest piece of code for an inputbox as:

"Enter Your Name"

1. If nothing is entered and OK is pressed:
msgbox("Nothing has been entered. Please RETRY")

2. If Cancel is pressed:
msgbox("You have cancelled the operation")

3. If something is entered and OK is pressed:
msgbox("You are " & Nme)

I have also found that codes do not work similarly enough in respect of the
TYPE of the inputbox to be Text or Cell Reference/Range Based, i.e. for
Type:=2 or Type:=8 any reference for relevant material on net.

Thanx in advance.

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default A simple inputbox & responding msgbox coding

Application.InputBox returns a Boolean for Cancel. So dimensioning the
variable as Variant equips the variable to handle both scenarios.

On the otherhand InputBox returns a vbNullString ("")

If this post helps click Yes
---------------
Jacob Skaria


"FARAZ QURESHI" wrote:

Thanx Jacob,

I don't understand why my previous reply didn't appear, however, would only
a Variant Data Type be used even when a String is expected as an input?

"Jacob Skaria" wrote:

Can you explain the issue referring to the example below...

Sub TestInputBox()
Dim varInput As Variant
InputBox:
varInput = Application.InputBox("Enter your name", Type:=2)
If varInput = False Then
MsgBox "You have cancelled the Operation": Exit Sub
ElseIf varInput = "" Then
MsgBox "Nothing has been entered. Please RETRY": GoTo InputBox
Else
MsgBox "You are " & varInput
End If
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"FARAZ QURESHI" wrote:

I sure woul oblige for the simplest piece of code for an inputbox as:

"Enter Your Name"

1. If nothing is entered and OK is pressed:
msgbox("Nothing has been entered. Please RETRY")

2. If Cancel is pressed:
msgbox("You have cancelled the operation")

3. If something is entered and OK is pressed:
msgbox("You are " & Nme)

I have also found that codes do not work similarly enough in respect of the
TYPE of the inputbox to be Text or Cell Reference/Range Based, i.e. for
Type:=2 or Type:=8 any reference for relevant material on net.

Thanx in advance.

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default A simple inputbox & responding msgbox coding

Dear Faraz

Your reply has gone to the post just below...It happens with me too quite
often...

If this post helps click Yes
---------------
Jacob Skaria


"FARAZ QURESHI" wrote:

Thanx Jacob,

I don't understand why my previous reply didn't appear, however, would only
a Variant Data Type be used even when a String is expected as an input?

"Jacob Skaria" wrote:

Can you explain the issue referring to the example below...

Sub TestInputBox()
Dim varInput As Variant
InputBox:
varInput = Application.InputBox("Enter your name", Type:=2)
If varInput = False Then
MsgBox "You have cancelled the Operation": Exit Sub
ElseIf varInput = "" Then
MsgBox "Nothing has been entered. Please RETRY": GoTo InputBox
Else
MsgBox "You are " & varInput
End If
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"FARAZ QURESHI" wrote:

I sure woul oblige for the simplest piece of code for an inputbox as:

"Enter Your Name"

1. If nothing is entered and OK is pressed:
msgbox("Nothing has been entered. Please RETRY")

2. If Cancel is pressed:
msgbox("You have cancelled the operation")

3. If something is entered and OK is pressed:
msgbox("You are " & Nme)

I have also found that codes do not work similarly enough in respect of the
TYPE of the inputbox to be Text or Cell Reference/Range Based, i.e. for
Type:=2 or Type:=8 any reference for relevant material on net.

Thanx in advance.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Returning a cell address in a msgbox, by selection via inputbox Ty FARAZ QURESHI Excel Discussion (Misc queries) 3 April 8th 09 12:57 PM
Help with InputBox and MsgBox Ann New Users to Excel 2 April 11th 07 03:46 PM
msgbox / inputbox etc samenvoegen van sheets Excel Discussion (Misc queries) 2 March 16th 06 08:56 AM
msgbox / inputbox etc samenvoegen van sheets Excel Worksheet Functions 2 March 15th 06 04:28 PM
msgbox / inputbox etc samenvoegen van sheets Setting up and Configuration of Excel 1 March 15th 06 03:32 PM


All times are GMT +1. The time now is 09:13 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"