Click to See Complete Forum and Search --> : Count data in a Textbox


sawscapes
April 28th, 2001, 10:18 PM
Can someone tell me how to code a textbox to count the number of letters or characters that a user inputs into that textbox? Then I need to calculate the letters, if letters >= to 100 then charge $4.20, and .02 for each letter over 100.
I have a label to enter the number of characters and a label that displays the cost.I don't know how to do the Dim part or the count.

slcotten
April 29th, 2001, 05:17 AM
In the event you want to calculate this, put something like:


Dim fLetters as Single ' This goes just before your sub declaration i.e "private Sub ....."
Dim fCharge as Single

' This assumes there is a label called lblLetters
' and a label called lblCharge
' it also assumes that lblLetters contains the amount of letters in the textbox

fLetters = CSng(lblLetters.Caption) ' get number of letters from label and convert to single

If fLetters >= 100 then
fCharge = 4.20 + ((fLetters - 100) * .02)
End If





Hope that this is something like what you're looking for... if not reply again.
Best of Luck,
slcotten :-)

shree
April 29th, 2001, 08:52 AM
private sub command1_click()
dim numLetters as integer
dim amt as single
numLetters = len (text1.text)
amt = 4.2
if numletters >= 100 then
amt = 4.2 + 0.02 * (numletters - 100)
end if
label1.caption = numletters
label2.caption = amt
end sub