Jumat, 24 Juli 2015

RE: [MS_AccessPros] Re: What does the colon do in the ELSE: statement?

 

Surely, it should be

 

 

   If 1 > 4 Then

      MsgBox "1 is greater than 4"

  Else

      MsgBox "1 is less than 4"

  End If

 

Or even

 

  MsgBox "1 is " & IIf(1 > 4, "greater", "less") & " than 4"

 

Multiple statement lines just don't feel right to me.

 

From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: 24 July 2015 16:24
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Re: What does the colon do in the ELSE: statement?

 

 

Phucon

 

As per Duane's explanation, the code should have been written:

 

   If 1 > 4 Then

      MsgBox "1 is greater than 4"

  Else: MsgBox "1 is less than 4"

  End If

 

Regards,

Bill Mosca, Founder - MS_Access_Professionals

Microsoft Office Access MVP

My nothing-to-do-with-Access blog

 



---In MS_Access_Professionals@yahoogroups.com, <duanehookom@hotmail.com> wrote :

I found this while searching the web http://stackoverflow.com/questions/7649101/excel-vba-pound-and-colon-signs-meaning
 
"The colon (:) is a statement delimiter. It would be equivalent to a new line in VBA, or a semicolon in C (just to quote a random example). It allows you to write several instructions on a single line rather than going to a new line each time."
 
Since your example code has not instruction on the same line after the ":" it serves no purpose.
 
Duane Hookom, MVP
MS Access
 


To: MS_Access_Professionals@yahoogroups.com
From: MS_Access_Professionals@yahoogroups.com
Date: Thu, 23 Jul 2015 08:21:06 -0700
Subject: [MS_AccessPros] What does the colon do in the ELSE: statement?



 
Hello
 
I am trying to understand the "ELSE:". Why is the colon necessary? What does it do there?
 
Thank you
 
Phucon
 
Sub IF_ELSEIF_FUNCTION()
  If 1 > 4 Then
      MsgBox "1 is greater than 4"
  Else:
      MsgBox "1 is less than 4"
  End If
End Sub


 

 

__._,_.___

Posted by: "Bob Phillips" <bob.phillips@dsl.pipex.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (4)

.

__,_._,___

Tidak ada komentar:

Posting Komentar