I got a textbox, from where people can add textstrings to a listbox.
From there, I want, once a person clicks "Start", the program types the first string from the list. After the interval the second, and so on. After it's had all of them, I want it to start at the top of the list again and repeat the action.
I already got a start button, but when I click it, it doesnt seem to read from the listbox and type them on the screen.
Could anyone help me getting this straight ?
Thanks,
Evolution445
10 7645
I got a textbox, from where people can add textstrings to a listbox.
From there, I want, once a person clicks "Start", the program types the first string from the list. After the interval the second, and so on. After it's had all of them, I want it to start at the top of the list again and repeat the action.
I already got a start button, but when I click it, it doesnt seem to read from the listbox and type them on the screen.
Could anyone help me getting this straight ?
Thanks,
Evolution445
You forgot to post the code that's not working
Oh, sorry, here it is: -
Private Sub msglist_Click()
-
Dim message As String
-
Dim currentmsg As Integer
-
currentmsg = currentmsg + 1
-
message = msglist.list(currentmsg)
-
End Sub
-
Edit:
This is the code I got in the Listbox. In the timer, thats activated with the startbutton, I only have the bit that it presses Enter, which also doesnt seem to work: -
Private Sub msgtimer_Timer()
-
SendKeys (vbKeyReturn)
-
End Sub
-
Anyone got any idea on solving this problem and get the list and pressing enter to work ?
This should work - Option Explicit
-
Dim lngPrevItem As Long
-
Dim blnRunning As Boolean
-
-
Private Sub Command1_Click()
-
'Command button to add text to listbox
-
List1.AddItem Text1.Text
-
Text1.Text = ""
-
End Sub
-
-
Private Sub Command2_Click()
-
'command button to start timer
-
If blnRunning Then Command2.Caption = "Start" Else Command2.Caption = "Stop"
-
blnRunning = blnRunning = False
-
msgtimer.Enabled = blnRunning
-
End Sub
-
-
Private Sub msgtimer_Timer()
-
'Timer to send keystrokes
-
If lngPrevItem = List1.ListCount - 1 Then lngPrevItem = -1
-
lngPrevItem = lngPrevItem + 1
-
SendKeys List1.List(lngPrevItem), 10
-
End Sub
-
-
Private Sub Form_Load()
-
Text1.Text = ""
-
Command1.Caption = "Add"
-
Command2.Caption = "Start"
-
msgtimer.Enabled = False
-
msgtimer.Interval = 1000
-
End Sub
Somehow it just doesnt seem to be working. It also refuses to press enter.
Would this be right to make it press enter after the message has been typed ?
SendKeys (vbKeyReturn)
Could it maybe be that it types the text, and presses Enter at the same time ?
Would there be an easy code to make it wait about 100 milliseconds ?
use vbCr:
SendKeys List1.List(lngPrevItem) & vbCr, 10
Thanks a lot, as it worked. But now I upgraded to VB2005. (The one currently on Microsoft's website)
I managed to change the code a bit so it would work in my eyes, but now it just writes: False, instead of the message from the listbox.
Here's the code from my current timer. -
Private Sub msgtimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles msgtimer.Tick
-
Dim lngPrevItem As Long
-
If lngPrevItem = msglist.Items.Count - 1 Then lngPrevItem = -1
-
lngPrevItem = lngPrevItem + 1
-
SendKeys.Send(msglist.Items.Count = (lngPrevItem))
-
SendKeys.Send("{ENTER}")
-
End Sub
-
Anyone got any idea on fixing this ?
Then another question,
How do I let - (just this timer/application, as it's for a multiplayer game) - wait 100 milliseconds after the first Sendkeys ?
Regards,
Evolution445
This... "msglist.Items.Count = (lngPrevItem)" is a comparison, which will return True or False. So that's what I would expect to be sent by the SendKeys in line 5.
Oh, i see, stupid me !
It's now working as it should, thanks all :)
Oh, i see, stupid me !
It's now working as it should, thanks all :)
:) I wish I had a dollar for every "stupid" bug I've created.
Glad we could help.
Jolie, I've split off your message to this new discussion thread, so it is more likely to attract a response.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mad |
last post by:
Hello to all, I am new to vb6 and I have been trying to make a listbox with
a horizontal and vertical scrollbar. For example, like the one on the
program Address book that is found on all Windows...
|
by: madhu |
last post by:
Hello
I am new to vb.net
1) I have 2 listboxs Named as list1 and list2 and 3 Buttons add and
the next one is remove buttons, read button
on click of add button the selected item from the...
|
by: Bill Dudek |
last post by:
Does vb.net have a listbox with a checkbox style like in vb6? I didn't
even see a style option under properties. I'm just starting in .net
and am trying to port an existing application over.
...
|
by: BVH |
last post by:
Hi,
I'm currently having a problem with a vb6 project I once wrote that
needs to be converted to vb.NET.
The problem is as follows :
On a form I have a listbox and two commandbuttons. The 2...
|
by: Bilal Abbasi |
last post by:
I realize that you can add items to a list box as objects so you can have
access to more than just one property like the itemindex in vb6. Question I
have is how do I cause the listbox to show a...
|
by: CR |
last post by:
In VB6 if I wanted to display a group of records, and possibly allow
the user to select one or more records, I would use the ListBox. For
example suppose I wanted to display something like this:
...
|
by: Steven Blair |
last post by:
I need to write an ASP.NET application which can do the following:
1. Create a socket which will stay alive and continously read data.
2. The data read needs to be displayed on the webpage.
3....
|
by: newsaboutgod |
last post by:
I think VB.NET drives some people crazy because some simple VB6 things
seem so hard.
Here is some VB6 code:
'Write CSV File
open "c:\test.csv" for output as #1
write#1, "1","2","3","4","5"...
|
by: Sunray |
last post by:
I have a form called the sales form and i have 2 sets of listboxes
So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |