I have a userform which uses various text boxes operated via spinbuttons.
I successfully use the following code to vary the date:
I thought that life would be easier for the users if I also gave the weekday in the test box and so changed the format of "dd mmmm yyyy" which produces 19 April 2018 to "dddd dd mmmm yyyy" which should give Friday 19 April 2018.. Everything starts off OK, but when I try to spin up or down, I get the message "Run-time error 13.Type mismatch" Yet I have only changed the format. Can anyone please explain why I get the error message!
Thanks
I successfully use the following code to vary the date:
Code:
Private Sub SpinButton1_SpinDown()
TextBox1.Text = Format(CDate(TextBox1.Text) - CDate(SpinButton1.SmallChange), "dd mmmm yyyy")
End Sub
Private Sub SpinButton1_SpinUp()
TextBox1.Text = Format(CDate(TextBox1.Text) + CDate(SpinButton1.SmallChange), "dd mmmm yyyy")
End Sub
Private Sub UserForm_Initialize()
TextBox1.Text = Format(Date, "dd mmmm yyyy")
End Sub
I thought that life would be easier for the users if I also gave the weekday in the test box and so changed the format of "dd mmmm yyyy" which produces 19 April 2018 to "dddd dd mmmm yyyy" which should give Friday 19 April 2018.. Everything starts off OK, but when I try to spin up or down, I get the message "Run-time error 13.Type mismatch" Yet I have only changed the format. Can anyone please explain why I get the error message!
Thanks