Welcome to Dream.In.Code
Become a VB Expert!

Join 149,532 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,525 people online right now. Registration is fast and FREE... Join Now!




Simple beginners VB prob

 
Reply to this topicStart new topic

Simple beginners VB prob

Olly Warburton
13 Sep, 2001 - 06:21 PM
Post #1

New D.I.C Head
*

Joined: 13 Sep, 2001
Posts: 1

GRRRRRRRR Why wont my code work? I have defintitely named my textbox right. What am I doing wrong? I want to create a loop that makes the text box count from 1 to 10000000

Private Sub CmdGo_Click()

Dim intTxtNumber As Integer
Dim i As Integer

intTxtNumber = i
intTxtNumber.Text = intTxtNumber

For i = 1 To 100000000
 
Next i

MsgBox ("Finished")

End Sub

User is offlineProfile CardPM
+Quote Post

sw00zh
RE: Simple Beginners VB Prob
3 Oct, 2001 - 09:37 AM
Post #2

New D.I.C Head
*

Joined: 13 Aug, 2001
Posts: 35

try this:
Private Sub CmdGo_Click()

Dim intTxtNumber As Integer
Dim i As Integer


For i = 1 To 100000000
intTxtNumber = i
intTxtNumber.Text = intTxtNumber
Next i

MsgBox ("Finished")

End Sub

I don't know if its working, cause my VB crashes everytime  :(

User is offlineProfile CardPM
+Quote Post

DestroyerOfWorlds
RE: Simple Beginners VB Prob
30 Dec, 2001 - 07:01 PM
Post #3

D.I.C Head
**

Joined: 11 Oct, 2001
Posts: 55

heres a code that will work, it increments the message box number. was that the effect you wanted?
CODE

Private Sub Command1_Click()
For i = 1 To 10

MsgBox (i)
Next i

End Sub


User is offlineProfile CardPM
+Quote Post

xilica
RE: Simple Beginners VB Prob
28 May, 2002 - 08:02 PM
Post #4

New D.I.C Head
Group Icon

Joined: 28 May, 2002
Posts: 0

Here is the code I have programmed:

CODE

Private Sub Command1_Click()

Dim i As Long

For i = 1 To 1000
Text1.Text = i
Next

MsgBox ("Finished")

End Sub


User is offlineProfile CardPM
+Quote Post

Techni
RE: Simple Beginners VB Prob
29 Jun, 2002 - 04:10 PM
Post #5

New D.I.C Head
*

Joined: 29 Jun, 2002
Posts: 3

if it only shows the last number, put a doevents inside the loop
User is offlineProfile CardPM
+Quote Post

ragingben
RE: Simple Beginners VB Prob
7 Oct, 2008 - 07:28 AM
Post #6

D.I.C Head
Group Icon

Joined: 7 Oct, 2008
Posts: 60



Thanked: 2 times
Dream Kudos: 100
My Contributions
Also, this will crash out as if you want to count to a million you will need a larger data type than an integer. An integer can only contain numbers upto 32767 (or -32767) so once you set it off counting (which will see providing you use doevents - as said previous) it will get to 32767 and then you will get a runtime error.

Instread use Long data type - it will count much beyond your requirements
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 09:00PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month