Question: I'm trying to work out how to work If statements while creating a function in Google Spreadsheets.

I've provided an example of what I'm trying to achieve. To the best of my knowledge, the If statement in this code simply checks that the value of cell A4 is equal to 4, and if so then it multiplies the input number by 1.5? However, when I try to run the function it always returns 0 (or whatever value I assign the price variable to begin with).

Any help would be much appreciated.

Many thanks

```
    function calculatePrice(inNum) {

         var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
         var price = 0;

         if (sheet.getRange(1, 4).getValue() == 4) {
             price = inNum * 1.5;
         }

         return price;
     }

```

Answer: 
The first example you showed is made using WPF which is quite easy to do *if you already know WPF*. The second example looks like Photoshop which is most likely a custom C++ Win32 control.

But if you're working with WinForms you usually can't do these kinds of customizations with the standard controls. You can write your own TabControl by deriving from Control and handling the painting and input yourself, which I've done in the past, but it's a lot of work too. Especially if you take into account that you have to manage a list of child controls for each tab. And that you may want design-time support for dragging and dropping other controls and panels into each tab and modifying the tab properties in the Visual Studio Designer. None of that is done for you if you go this route.

If you don't want to learn WPF, and you don't want to spend the week(s) it could take to write a robust custom control, you could look at companies such as Telerik, DevExpress, Infragistics, etc., you might be able to simply pay for a control library which a TabControl that already does this.
Here's a dumb way to do it...

Add some spaces and an X at the end of the tab name. In the click even capture the Mouse X and see if it is over the X.

```
Private Sub TabControl1_Click(sender As System.Object, e As System.EventArgs) Handles TabControl1.Click
    Dim m As System.Windows.Forms.MouseEventArgs = DirectCast(e, System.Windows.Forms.MouseEventArgs)
    Dim tabWidth As Integer =
        Convert.ToInt32(Me.CreateGraphics().MeasureString(TabControl1.SelectedTab.Text, TabControl1.Font).Width)
    Debug.Print(m.X & " " & m.Y & " " & tabWidth)
End Sub

```

A Sub/Func is needed to calculate the hot spots accounting for which tabs are displayed. Iterate over the visible tabs and use the tabWidth as shown above to do the math.