LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Calculating a textbox on a userform

I have a stumbling block in my code below.

If I do not assign a value to ComboBox11 (and the default value I want is 0)
then I get a type mismatch error when I start to enter a number in TextBox2.
If I do assign a value to ComboBox11 (using .ComboBox11.Value = "0") then
everything works with the notable exception that I when I use the dropdown
on the ComboBox to select one of my other choices (0, .5, 1) I can not
change the value. It remains at 0 no mater what I do.

Anyone have any thoughts on this?



Sub TotalHours1()

Dim bTest1 As Boolean
Dim bTest2 As Boolean
Dim bTest3 As Boolean
Dim dblElapsed

With UserForm1

.ComboBox11.Value = "0"

If IsNumeric(.TextBox1.Text) And _
IsNumeric(.TextBox2.Text) Then

dblElapsed = (CDbl(.TextBox2.Text) - CDbl(.TextBox1.Text) -
CDbl(.ComboBox11.Text))

.TextBox3.Value = Format(dblElapsed, "#0.00")

If .ComboBox1.Value = "" Then GoTo EnterCode
GoTo EndMacro

EnterCode:

.ComboBox1.Value = "01"

Else

'MsgBox "There is an invalid time"

End If

GoTo EndMacro

ClearBox:

UserForm1.TextBox1.Value = Format("", "")
UserForm1.TextBox2.Value = Format("", "")
UserForm1.TextBox3.Value = Format("", "")

EndMacro:

End With

End Sub


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
userform textbox Phil Excel Worksheet Functions 5 January 16th 05 06:59 PM
How to add textbox/buttons to an UserForm Terence[_2_] Excel Programming 2 August 7th 03 08:56 AM
hide a textbox on a userform? Bill Lunney Excel Programming 2 July 31st 03 08:57 AM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM
Help with Syntax UserForm TextBox John Wilson Excel Programming 1 July 28th 03 04:15 PM


All times are GMT +1. The time now is 08:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"