Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript Problem - Variable Increment

Status
Not open for further replies.

lennitw

Programmer
Jan 10, 2006
13
US
Below is code I use to populate some text boxes. The problem is that when the user presses a button, a new row of text boxes appears and I need this code to point to them and leave the data in the previous row. For example, the way it is coded it will only work with the text box (document.frmMS47.SpaceTypeTask2) but if a new row is added I need it to work with (document.frmMS47.SpaceTypeTask3).

Ideas?

=============

<script language=VBScript>
sub window_onLoad
PopulateTextbox
end sub

sub PopulateTextbox()
dim x, scX, space_comp, taskid, minper, spacetype, newtime, checktime
x = 0
y = 2
scX = 0
space_comp = ""
taskid = ""
minper = 0


do until x > LEN(document.frmMS47.SpaceTypeTask2.value)
if right(left(document.frmMS47.SpaceTypeTask2.value,x),1) = "-" AND space_comp = "" then
space_comp = left(document.frmMS47.SpaceTypeTask2.value,x-1)
scX = x
x = x + 1
end if
if right(left(document.frmMS47.SpaceTypeTask2.value,x),1) = "-" AND taskid = "" then
taskid = right((left(document.frmMS47.SpaceTypeTask2.value,(x-1))),x-scx-1)
xx = x
minper = right(document.frmMS47.SpaceTypeTask2.value, LEN(document.frmMS47.SpaceTypeTask2.value) - x)
x = LEN(document.frmMS47.SpaceTypeTask2.value)
end if

x = x + 1
loop

document.frmMS47.TimePerSqFt2.value = minper

checktime = document.frmMS47.endtime0.value

myDec = InStr(1, CStr(minper * document.frmMS47.sqFT_Fix2.value), ".", vbTextCompare)
If myDec > 0 Then
roundUp = CDbl(Left(CStr(minper * document.frmMS47.sqFT_Fix2.value), myDec)) + 1
Else
roundUp = minper * document.frmMS47.sqFT_Fix2.value
End If

newtime = (DATEADD("n",((roundUp)),checktime))
document.frmMS47.endTime2.value = formatdatetime(newtime,4)

document.frmMS47.startTime2.value = formatdatetime(checktime,4)

end sub
</script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top