Microsoft Visual Studio .NET: It's Dot Com!

I have (re)discovered the joys of Visual Basic! But anyway, in lieu of any available textbooks telling me how to do stuff, I wanna know:

  1. How to get it to “wait X seconds” before doing something
  2. How to make text and/or pictures appear outside a Form
  3. Either how (if possible) to make a String array with an unspecified amount of elements (I’m going to be reading from a file, and to get each line will involve a different command), or how to select differing elements of a single string (i.e. select line 3 of the string “Five syllables, then(newline)seven and then five again.(newline)All in all, three lines.”)
  4. How to get a text box set “multiline” to actually BE multiline when you set a string to it! (Trying to set the text box’s text as the above string simply makes it “Five syllables, thenseven and then five again.All in all, three lines.”)
  1. You need to use a timer. Set the interval in milliseconds, and if you don’t want it to start initially, just leave it disabled and enable it as you need it.

  2. Not a clue. I’ve never seen anything like that.

  3. Just dimension it without any parameters initially (i.e. “Dim String()”), and then you can redimension it later with a variable (i.e. “ReDim String(Integer)” or “ReDim Preserve…” if you need to keep the contents of the array). You can also use the Split function to separate stings.

  4. Are you asking how to insert new lines? Try “Textbox.Text = ‘first line’ & vbCrLf & ‘second line’”

VB isn’t so bad, but there isn’t really all that much you can really do with it, in my opinion. If you can figure out how to use MFS or Qt or some such graphical set, then C++ would probably be the best for graphical environments, due to the limitations of VB, and ASM for console apps.

Okay … use a timer how, exactly? Like, what commands do you use if you want to wait a randomized amount of seconds, then turn the form’s background blue for five seconds, then change it back?

Alright… First you need to place a timer on your form. Then on form load, you can set an integer to some random value. I believe timers only go up to two minutes, so you could do RandomInteger = Int(120000 * Rnd + 1), and then set that as the Interval. Or, more efficiantly, you could just do something like “Timer.Interval = Int(120000 * Rnd + 1)”.

Then, under the timer’s section of your code, you could do
Form.BackColor = vbBlue
Timer2.Interval = 5000
Timer2.Enabled = True
and “Form.BackColor = &H8000000F” under Timer2’s code, assuming Timer2 was not enabled initially.

Microsoft’s new .COM platform

All righty then … how about if I want to loop something in a timer? Like, make a text box (txtText, for the purposes of this example) count down from ten to one using a variable and “intInteger = intInteger - 1”? (i.e. it says “10” then waits a second then “9” and so on)

Here’s some simple code that needs only txtText and tmrTimer on a form that will count from 10 to zero, and then exit.

Private Sub Form_Load()
tmrTimer.Interval = 1000
txtText.Text = “10”
End Sub

Private Sub tmrTimer_Timer()
Dim intCount As Integer
intCount = txtText.Text
txtText.Text = intCount - 1
If intCount = 1 Then End
End Sub

The timer automatically begins again when its code is executed, so it’s completely unnessesary to use loops or anything.

… and wouldn’t you know it but I’ve forgotten how to go to another form. >_>

Heh… it’s “frmWhatever.Show” :stuck_out_tongue:

Hmm … doesn’t seem to work in Visual Studio .NET …