• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Need some VB Help

Status
Not open for further replies.
Level 22
Joined
Feb 3, 2009
Messages
3,292
My code:

Public Class Form3

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim Random(65) As String
Dim chance As Integer = 8
If chance <= 0 Then
Timer1.Enabled = False
Else
Random(0) = "0"
Random(1) = "1"
Random(2) = "2"
Random(3) = "3"
Random(4) = "4"
Random(5) = "5"
Random(6) = "6"
Random(7) = "7"
Random(8) = "8"
Random(9) = "9"
Random(10) = "a"
Random(11) = "b"
Random(12) = "c"
Random(13) = "d"
Random(14) = "e"
Random(15) = "f"
Random(16) = "g"
Random(17) = "h"
Random(18) = "i"
Random(19) = "j"
Random(20) = "k"
Random(21) = "l"
Random(22) = "m"
Random(23) = "n"
Random(24) = "o"
Random(25) = "p"
Random(26) = "r"
Random(27) = "s"
Random(28) = "t"
Random(29) = "u"
Random(30) = "v"
Random(31) = "z"
Random(32) = "x"
Random(33) = "y"
Random(34) = "q"
Random(35) = "w"
Random(36) = "A"
Random(37) = "B"
Random(38) = "C"
Random(39) = "D"
Random(40) = "E"
Random(41) = "F"
Random(42) = "G"
Random(43) = "H"
Random(44) = "I"
Random(45) = "J"
Random(46) = "K"
Random(47) = "L"
Random(48) = "M"
Random(49) = "N"
Random(50) = "O"
Random(51) = "P"
Random(52) = "R"
Random(53) = "S"
Random(54) = "T"
Random(55) = "U"
Random(56) = "V"
Random(57) = "Z"
Random(58) = "X"
Random(59) = "Y"
Random(60) = "Q"
Random(61) = "W"
Dim Random2 As New Random
TextBox1.Text = TextBox1.Text + Random(Random2.Next("62"))
chance = chance - 1
End If

End Sub
End Class


Well it doesn't want to ever end, at all, even i set the if, that it would only write 8 chars, but i just doesn't want to stop.... pls help
 
Level 11
Joined
Feb 14, 2009
Messages
884
Your code doesn't work cause each time Timer ticks, chance becomes 8, every time. The following code may help you. It would also be a good idea to declare variables outside the timer code. Maybe in the Form_Load event or in module.

Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim i as Integer
Dim Random(65) as String
Dim Char as Integer

For i = 1 to 8
    Char = CInt (Int(65) * Rnd() + 1)
    Text1.Text = Text1.Text & Random(Char)
Next i

End Sub
 
Level 11
Joined
Feb 14, 2009
Messages
884
Aw, now you're getting really deep. You say that you want to implement something like an auto-updater, right? This is possible, but I'm afraid you have to write a script in another language, like Perl. What you can do, however, is to have a button that will redirect to your website and so users can check if a new version is available. About the updates, I don't know how you can patch VB applications, but I've read that it's really troublesome. I'll see what I can do though and I'll keep you updated :)
 
Level 22
Joined
Feb 3, 2009
Messages
3,292
Too bad, i don't have a webpage :(

Edit another question appears now (i know it's getting anoying)

i know how to make shutdown with time:

Shell ("shutdown -s -t 10") but now i'd like the -c (-c is for comment)
but i don't know how to add it

Shell ("shutdown -s -t 10 -c no idea how to continiue it from here...
 
Level 11
Joined
Feb 14, 2009
Messages
884
Take a look at this. I'm sure you'll like it. It's an all-purpose library which features some extremely helpful tools. Shutdown function included :)
 
Status
Not open for further replies.
Top