Question: I have a simple Sub to set a checkbox (placed on a worksheet) depending on whether or not a Worksheet is protected.

`chkToggleProtect` absolutely exists, by I'm getting a compile error on either of the lines where I reference it -

> 
> Variable not defined
> 
> 
> 

Any ideas what I'm doing wrong?

```
Private Sub SetToggleProtect(ByRef isprotected As Boolean)

    If isprotected Then
        chkToggleProtect.Checked = True
    Else
        chkToggleProtect.Checked = False
    End If

End Sub

```

Answer: 
Try to use like this....

```
 [nearestLocation addAttribute:NSForegroundColorAttributeName value:[UIColor brownColor] range:NSMakeRange(0,[nearestLocation length])];

```
```
    NSString *tempString=@"your string";   
    NSMutableAttributedString *attString=[[NSMutableAttributedString alloc]  initWithString:tempString];                                                                                     
    int lenght=(int)[tempString length];   
    [attString addAttribute:(id)NSForegroundColorAttributeName value:[UIColor brownColor] range:NSMakeRange(0,lenght)];  
    [attString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:2] range:NSMakeRange(0, length)];

    UIButton *hyperLinkButton=[UIButton buttonWithType:UIButtonTypeCustom];
    hyperLinkButton.frame=CGRectMake(30, 5, 100, 30);
    [hyperLinkButton setAttributedTitle:attString forState:UIControlStateNormal];
    hyperLinkButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    hyperLinkButton.tag=[[[[[[personalDetailDictionary objectForKey:@"Acknowledgements"] objectForKey:@"details"] objectAtIndex:i] objectForKey:@"tagValue"] objectForKey:@"text"] intValue];
    [hyperLinkButton addTarget:self action:@selector(hyperLinkAction:) forControlEvents:UIControlEventTouchUpInside];
    hyperLinkButton.titleLabel.textAlignment=NSTextAlignmentLeft;
    [self.view addSubview:hyperLinkButton];

```