Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Better way of writing the code

Posted on 2016-10-04
4
Medium Priority
?
54 Views
Last Modified: 2016-10-04
Hello,

  Is there a better of writing this code rather than repetition:

    If Me.BtnEditRecordHotelID.Enabled = True Then
                    ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")
                Else
                    ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")
                    Exit Sub
                End If

Open in new window


Cheers
0
Comment
Question by:RIAS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Accepted Solution

by:
Paweł earned 2000 total points
ID: 41827777
since it looks as if you're formating is the same why not pull it out of the if and just exit the sub if the Me.BtnEditRecordHotelID.Enable is false


ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")

 If Me.BtnEditRecordHotelID.Enabled = false
     Exit Sub
End If
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 41827779
   ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")

  If Me.BtnEditRecordHotelID.Enabled = False Then
        Exit Sub
End If

Open in new window

1
 
LVL 53

Expert Comment

by:Rgonzo1971
ID: 41827783
Hi,

maybe
ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")
If Me.BtnEditRecordHotelID.Enabled = False Then Exit Sub

Open in new window

Regards
1
 

Author Comment

by:RIAS
ID: 41827785
Cheers!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question