1 Replies - 485 Views - Last Post: 14 November 2017 - 07:28 AM Rate Topic: -----

#1 norbski66   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-November 17

VBA Excel Textbox Object

Posted 14 November 2017 - 07:22 AM

Hi.
I've been searching all over and cannot find an answer to this.
I have a form in Excel VB in which the user inputs a date in three separate text boxes (DD MM YY)
For each text box, I have the following code to check that the input is valid
Dim SetDD as object

DDCheckVal = TextDD.Value
Set ChkDD

DDCheckVal is a public variable which is passed to a DateCheck Function

Function DateCheck()

if DDCheckVal <0 or DDCheckVal >31 then 
Call InvalidCode
else:
end if

End Function


So Far So good, this all works ok. Now what I want the InvalidCode Function to do is change the colour of the cell using the textbox name as a variable and setting the .backcolor property.
Function InvalidCode (ChkDD as object)

ChkDD.backcolor=rgb(255,0,0)

End Function
:code:/>

The problem seems to be that I can't set ChkDD to TextDD. It keeps returning the Value of the text box instead of the text box name.

Sorry if I've not explained it very well

Thanks in advance of your help

This post has been edited by modi123_1: 14 November 2017 - 07:49 AM
Reason for edit:: In the future, please use the [code] tag button in the editor.


Is This A Good Question/Topic? 0
  • +

Replies To: VBA Excel Textbox Object

#2 norbski66   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 14-November 17

Re: VBA Excel Textbox Object

Posted 14 November 2017 - 07:28 AM

Sorry
Dim SetDD as object

should read

Dim chkDD as object

Set ChkDD should read
SetChkDD = TextDD

Can't see an edit button anywhere
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1