![]() |
|
|
#1 | ||
|
College Prospect
Join Date: Aug 2005
|
Programming help
With VB6, how can I do a program that will, with a button click, copy a line from a text file and paste it in a text box? Like, let's say I have this text file:
Code:
I want my program to copy a random name to the text box every time I click on the button. The first click my give me Berg, while the second give me Hull. If you know how to do this, can you give me a code that could help? |
||
|
|
|
|
|
#2 |
|
Coordinator
Join Date: Jan 2002
Location: Hog Country
|
A simple to understand way of doing it would be to open the text file as an input file
f=freefile Open "sample.txt" for input as #f Then read in the names into an array do line input #f, name(x) x=x+1 loop until eof(f) = true Then select the random name n=int(rnd(1)*x) text1.text = name(n) Being careful to dimension and declare the proper variables, of course. |
|
|
|
|
|
#3 | |
|
College Prospect
Join Date: Aug 2005
|
Quote:
Thanks for such a quick answer! I'm going to look into it tommorow after work and I'm going to post again to tell if I was able to do it or not. Thanks again! |
|
|
|
|
|
|
#4 |
|
Coordinator
Join Date: Jan 2002
Location: Hog Country
|
Sure. If you need elaboration let me know.
|
|
|
|
|
|
#5 |
|
College Prospect
Join Date: Aug 2005
|
Thanks, it worked! I asked this on multiple VB forums and got no good answers, I kinda knew you guys would help me!
Thanks again, really appreciated! |
|
|
|
|
|
#6 |
|
High School Varsity
Join Date: Jan 2005
Location: New Jersey, USA
|
I'm curious: why are you doing this in VB6!? Especially when VB.NET and C# are available and significantly better.
|
|
|
|
|
|
#7 | |
|
College Prospect
Join Date: Jul 2001
Location: Newcastle, Australia
|
Quote:
My learning curve on VB6 has been over 4-5 years and I feel reasonably comfortable with it. I dl-ed VB 2005 ( or whatever the hell it's called ) and found it too different to go and learn. I've stuck with what I already know. |
|
|
|
|
|
|
#8 | |
|
Coordinator
Join Date: Jan 2002
Location: Hog Country
|
Quote:
If you are interested in getting a project working quickly and you already know VB6 well enought to get by, why would you want to learn an entirely new program (and vb.net is near enough to an entirely different language to use that analogy) just to make that project. It really is overkill for a lot of projects (and I have used both extensively). Plus VB6 usually makes faster, lighter, and easier to distribute packages (in my experience) for small projects. |
|
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|