Solved

Better way of writing the code

Posted on 2016-10-04
4
38 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 9

Accepted Solution

by:
Paweł earned 500 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 50

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 50

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

856 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