PDA

Click to See Complete Forum and Search --> : Need VBScript Help


elfstone
May 17th, 2000, 10:13 AM
Does anyone know how to "swap" the text in textbox 1 with
the text in textbox 2 on a form using only one line of
vbscript code?

kleve
May 18th, 2000, 09:10 PM
It's impossible :)

Now why do you want to do it in only 1 line?

RealisticGraphics
May 20th, 2000, 03:16 AM
dim txt1, txt2:txt1 = textbox1.text:txt2 = textbox2.text:textbox1.text = txt2:textbox2.text = txt1

(Please note this IS one line of code. Don't know if it'll word wrap or not so I thought I'd tell you that)


kleve: It's not impossible... There's just no point in doing it. however if somebody can give us one, let us know.

kleve
May 21st, 2000, 02:43 PM
Ok, it's possible to do it in one line of code, by putting ":"'s in. IMHO that's cheating ;)

What you've really got is 5 separate execution statements. To me a statement is a line of code, but I agree that it can be done in a single line, not a single execution statement.

I'd still like to know why thou :)

RealisticGraphics
May 22nd, 2000, 07:12 AM
He re-posted this in a new thread, and explained that he was looking for this because his professor said it was possible and he wanted to know how.

You can also create your own function.

Function SwitchBox(Text1, Text2)
dim txt1
txt1 = text1.text
text1.text = text2.text
text2.text = txt1
end function

Then call in code.

SwitchBox TextBox1, TextBox2

Of course, I realize this is not really on line of code, but I guess that just depends on how you look at it.