Solved

Better way of writing the code

Posted on 2016-10-04
4
29 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
4 Comments
 
LVL 8

Accepted Solution

by:
Paweł earned 500 total points
Comment Utility
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 49

Expert Comment

by:Ryan Chong
Comment Utility
   ClsFrmMain.FormatMessage(3, "HotelID Update : ", "", "HotelID Update")

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

Open in new window

1
 
LVL 48

Expert Comment

by:Rgonzo1971
Comment Utility
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
Comment Utility
Cheers!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now