By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,057 Members | 1,346 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,057 IT Pros & Developers. It's quick & easy.

Trying to calculate Text Box inputs - please help!

100+
P: 153
Hi,
I have been learning VB now for about a week and thought I was doing ok. I have already done a calculation form (not as big as this) . I have volunteered myself to help a friend input her hours per day into a form, start time, end time and lunch time. Then the form will calculate the amount of hours she has done for her. Sending results to access is not an issue yet!

When I have entered the below code and tested it, it let's me input hours, I press calculate then says compile error, method or data member not found. I press ok and .text is highlighted. I have noticed when I delete .text and type it again only 4 options instead of loads comes up. So really it's not letting me selct it as .text.

I was up til 4 this morning with this so any help and I would be eternally grateful.

Dim SunTotal As Variant
Dim MonTotal As Variant
Dim TuesTotal As Variant
Dim WedsTotal As Variant
Dim Thurstotal As Variant
Dim FriTotal As Variant
Dim SatTotal As Variant

Dim HoursTotal As Variant

Dim valsunend As Variant
Dim valmonend As Variant
Dim valtuesend As Variant
Dim valwedsend As Variant
Dim valthursend As Variant
Dim valfriend As Variant
Dim valsatend As Variant

Dim valsunstart As Variant
Dim valmonstart As Variant
Dim valtuesstart As Variant
Dim valwedsstart As Variant
Dim valthursstart As Variant
Dim valfristart As Variant
Dim valsatstart As Variant

Dim valsunlunch As Variant
Dim valmonlunch As Variant
Dim valtueslunch As Variant
Dim valwedslunch As Variant
Dim valthurslunch As Variant
Dim valfrilunch As Variant
Dim valsatlunch As Variant

Private Sub CmdCalculate_Click()
valsunend = Val(TxtSunEnd.Text)
valmonend = Val(TxtMonEnd.Text)
valtuesend = Val(TxtTuesEnd.Text)
valwedsend = Val(TxtWedsEnd.Text)
valthursend = Val(TxtThursEnd.Text)
valfriend = Val(TxtFriEnd.Text)
valsatend = Val(TxtSatEnd.Text)

valsunstart = Val(TxtSunStart.Text)
valmonstart = Val(TxtMonStart.Text)
valtuesstart = Val(TxtTuesStart.Text)
valwedsstart = Val(TxtWedsStart.Text)
valthursstart = Val(TxtThursStart.Text)
valfristart = Val(TxtFriStart.Text)
valsatstart = Val(TxtSatStart.Text)

valsunlunch = Val(TxtSunLunch.Text)
valmonlunch = Val(TxtMonLunch.Text)
valtueslunch = Val(TxtTuesLunch.Text)
valwedslunch = Val(TxtWedsLunch.Text)
valthurslunch = Val(TxtThursLunch.Text)
valfrilunch = Val(TxtFriLunch.Text)
valsatlunch = Val(TxtSatLunch.Text)


SunTotal = valsunend - valsunstart - valsunlunch
MonTotal = valmonend - valmonstart - valmonlunch
TuesTotal = valtuesend - valtuesstart - valtueslunch
WedsTotal = valwedsend - valwedsstart - valwedslunch
Thurstotal = valthursend - valthursstart - valthurslunch
FriTotal = valfriend - valfristart - valfrilunch
SatTotal = valsatend - valsatstart - valsatlunch

HoursTotal = SunTotal + MonTotal + TuesTotal + WedsTotal + Thurstotal + FriTotal + SatTotal
LblHours.Caption = HoursTotal


End Sub
Nov 30 '07 #1
Share this Question
Share on Google+
5 Replies


QVeen72
Expert 100+
P: 1,445
Hi,

Do you get Error on all the lines of "txt.Text"...?
Instead of Variant, Try to Decalare all the Variables as Single/Double Or Currency..

Regards
Veena
Nov 30 '07 #2

100+
P: 153
Hi,

Do you get Error on all the lines of "txt.Text"...?
Instead of Variant, Try to Decalare all the Variables as Single/Double Or Currency..

Regards
Veena
Hi I'll try it now,

Thanks for swift response - letyou know!
Nov 30 '07 #3

100+
P: 153
Hi, Changed all to double, same response. When you say on all lines I don't know because it only shows first line of problem:
Private Sub CmdCalculate_Click() (being in yellow)
valsunend = Val(TxtSunEnd.Text) (.text being highlighted blue.

The strange thing is that when I go to type something like text1.text on another project it'll offer me the option of filling .text in for me. This project isn't doing that. The auto fill has only 4 options - count, item, lbound and ubound.

Can't get my head around it.
Nov 30 '07 #4

QVeen72
Expert 100+
P: 1,445
The strange thing is that when I go to type something like text1.text on another project it'll offer me the option of filling .text in for me. This project isn't doing that. The auto fill has only 4 options - count, item, lbound and ubound.
Can't get my head around it.
Hi,

OK, By mistake, you have created a Control Array of TextBoxes.
In Design Mode, Go to the properties of each TextBox, and Clear Value from this property: "Index" (it will be some Integer value 0,1,..)

Just Take Care that No TextBox Name is Repeated..

Regards
Veena
Nov 30 '07 #5

100+
P: 153
Thank you so much it worked!
Nov 30 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.