Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Click Event Control Problem ...code Included!


the following code is from msdn example, however the private declaration that I put on top of the module gives problems...only possible (or something) in object module it says...

The intention is to create a menubar...that is not a problem so far...:-)...and when a user clicks on a controlbutton it has to detect wich control so that I can call a function and give a string with it...the string depends on wich control is pushed...


Code:
Private WithEvents ce As CommandBarEvents

Sub Test()
    Dim c As CommandBarControl
    Set c = Application.VBE.CommandBars("Tools").Controls(1)
    Set ce = Application.VBE.Events.CommandBarEvents(c)
End Sub

Private Sub ce_Click(ByVal CommandBarControl As Object, Handled As Boolean, CancelDefault As Boolean)
    ' Put event-handling code here
End Sub



Question 1 : The problem with the private declaration...how to solve? what do i do wrong?
             2 : Do I have to create this msdn example for all the controls in the menu or just one time and the control pushed is recognised?
 
An answer on this question solves all...Can I give the on Action for a control a funtion with an argument?????????????????????????? How to do this?


nitro...all help is welcome




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Double-click Event Firing Off Click Event Code?
For example:

In a listbox, I have a click event that changes a label's caption from 'Loaded' to 'Clicked' and changes the color from black to red.

I have a double-click event that shows a message box saying "I've been double-clicked."

You can re-set the label by clicking it.

When I click the listbox, the label's caption and color changes. This is what I expected.

When I double-click the listbox, the label's caption and color changes, and the message box is displayed. Why?????

Problem With Unit Attack In RTS Game (need Help With Control Arrays!)(code Included)
    I finished my computer class curriculum a couple months early, so I decided to tackle an ambitious project. The idea was to create a 2d game much like warcraft 2. I set about creating units, and made control arrays for both my units and their health bars. I did both unit selection and highlighting easily, and then movement. Finally I did attack. PROBLEM! The basic idea of my attack is that if a unit comes into contact with another unit. they fight, however when i wrote my code, only certain units would attack certain units because they shared the same index number. This may be the wrong terminology so i'll explain.
    Unit(0) can only attack Otherunit(0), not Otherunit(1)
    
    How do I fix this, if you need more details, i will try to provide them.


some stuff is added in code (attached)                
                    



Edited by - AceDudeVB on 4/27/2004 5:36:36 PM

Object Click Event Through Code
I have two forms, main form has a button that starts a routine. form two runs a timer that compairs two variable. Is it possible to activate the button code on form 1 when the variable match ? IE Once the variable match I would return to the first form but I need a way to let the form know to start the code in the BntStart_Click.

Anyone




Private Sub BtnStart_Click()
Dim result As Integer
Follow = False
SingleStep = False

end sub


VB.6 User, Since 2002
Next Generation Lighting Controls
www.jmelectronics-online.com

Raising The ActiveX Control's Event On The Click Of The ActiveX C Ontrol's Sub Form Buttton Click
Hi Friends,

I am designing one ActiveX Control with a lot of sub forms which r shown on
calling the methods or from some other events.
I want to raise few event of this ActiveX Control on the click of any button
of ActiveX control's sub form.
I want to give the user of the activex control some development control
with the help of these events.
I am not able to access the events (defined in the user control at design
time) of the activex control from the sub form of the activeX control.
Can anybody tell me how to do that.

Thnx in advance,

Naveen !!!!!

Raising The ActiveX Control's Event On The Click Of The ActiveX C Ontrol's Sub Form Buttton Click
Hi Friends,

I am designing one ActiveX Control with a lot of forms which r shown on
calling the methods or from some other events.
I want to raise few event of this ActiveX Control on the click of any button
of ActiveX control's sub form.
I want to give the user of the activex control some development controls
with the help of these events.
I am not able to access the event (defined in the user control at design
time) of the activex control from the form.
Can anybody tell me how to do that.

Thnkx in advance,

Naveen !!!!!

*SOLVED* Activating A Click Event With Code
I have indexed textboxes with click events...
Now i was wondering if i can activate the click events using code, and not having to actually click the textbox...

Any ideas?

Calling ListView Click Event Via Code
I have a Listview control click event that I need to be able to call via code.

I have a search routine and want to allow an option to select the correct entry and carryout the click routine.

I can find out the item selected from the search rountine, but I am unsure how to call the listview's click routine with the correct item number. I've tried lv_ItemClick(SRow), where SRow is an integer holding the found item, but got the error type mismatch.

Here is the click event I need to call. Thanks in advance for any help

private Sub lv_ItemClick(byval item as MSComctlLib.ListItem)
Dim i%

lv.MultiSelect = false
Label4.Visible = false
If Page% = 1 then
SaveEmp$ = First(0).Text
End If
i% = item
FEmp$ = lv.ListItems(i%).SubItems(2)
lblFirst(0).Caption = lv.ListItems(i%).SubItems(3)
DFile% = lv.ListItems(i%)
First(0).Text = lv.ListItems(i%).SubItems(2)
First(1).Text = lv.ListItems(i%).SubItems(4) * 100
First(2).Text = lv.ListItems(i%).SubItems(5) * 100
First(3).Text = lv.ListItems(i%).SubItems(6) * 100
First(4).Text = lv.ListItems(i%).SubItems(7) * 100
First(5).Text = lv.ListItems(i%).SubItems(8) * 100
First(6).Text = lv.ListItems(i%).SubItems(9) * 100
First(7).Text = lv.ListItems(i%).SubItems(10) * 100
First(8).Text = lv.ListItems(i%).SubItems(11) * 100
First(9).Text = lv.ListItems(i%).SubItems(12) * 100
First(10).Text = lv.ListItems(i%).SubItems(13)
First(11).Text = lv.ListItems(i%).SubItems(14) * 100
If First(12).Visible = true then
First(12).Text = lv.ListItems(i%).SubItems(15) * 100
First(13).Text = lv.ListItems(i%).SubItems(16) * 100
First(14).Text = lv.ListItems(i%).SubItems(17)
First(15).Text = lv.ListItems(i%).SubItems(18)
First(16).Text = lv.ListItems(i%).SubItems(19)
First(17).Text = lv.ListItems(i%).SubItems(20)
End If
First(18).Text = lv.ListItems(i%).SubItems(21) * 100
First(19).Text = lv.ListItems(i%).SubItems(22) * 100
First(20).Text = lv.ListItems(i%).SubItems(23) * 100
First(21).Text = lv.ListItems(i%).SubItems(24) * 100
If First(23).Visible = true then
First(22).Text = lv.ListItems(i%).SubItems(25)
First(23).Text = lv.ListItems(i%).SubItems(26) * 100
First(24).Text = lv.ListItems(i%).SubItems(27)
First(25).Text = lv.ListItems(i%).SubItems(28)
First(26).Text = lv.ListItems(i%).SubItems(29)
First(27).Text = lv.ListItems(i%).SubItems(30)
End If
fraEdit.Visible = true
If lv.ListItems(i%).SubItems(1) = "D" then
Command1(0).Visible = false
Command1(1).Visible = false
Command1(3).Visible = true
End If
Disable1
If Command1(0).Visible = true then
Command1(0).SetFocus
else
Command1(3).SetFocus
End If
End Sub

Calling Toolbar Button Click Event Through Code
Trying to execute/call the toolbar_click event through code. Does someone know how this is done in VB.NET?

Thanks,

O.

Image Control Click Event
i am using VB .NET
I have an image control which contains a .ico file. (in a .aspx page)
on the click event of this control(in .aspx.vb page), i want to show another page, which is a web link.
how do i do it?

Referencing A Control On The Click Event
I have numerous labels in a project. when i click on one of the labels i want to change the backstyle of all the labels in the form except the one i clicked on. i was able to use "for each ctrl in controls... next ctrl" function to change all of the labels, but could not identify which label was clicked. I don't want to "hard-code" the label since i would have to do this for each labels click event. any suggestions?

Click Event In Control Array
Hey there,

I created an image control array (at design time) and associated a different picture for each one to create a custom toolbox, like this:

image1(0)
image1(1)
image1(2)
.
.
.

Well, when I double-click over any image object to codify the click event, it goes to the code and shows Private Sub Image1_Click(). When I try to run the program, the compiler show the "Procedure declaration does not match description of event or procedure having the same name" error.

I know that it occurs because I have an array but the click event is referring to the images at generic way. What I don't know is how to solve that.

Any clues?

Thanks!

Control Array Click Event
i have an array of command buttons, how would i do a click event for them?

Help With User Control And Click Event
Hey everyone, I got a user control, not created by me, and the problem is the author of the control never really finished it, it looks as if he kinda just quickly put it together. I need to have a click event on the user control but dont quite understand how it works.

Here is an example of how the author used the KeyDown event:

VB Code:
Public Event KeyDown(KeyCode As Integer, Shift As Integer) Private Sub UserControl_KeyDown(KeyCode As Integer, Shift As Integer)' all keydown coding here...doesnt really matterEnd Sub

The thing is, there is no where through the rest of the code that triggers the KeyDown event...is this an event that vb will automatically trigger? And if so, it shouldnt be hard to make a click event..

So any suggestions on what I should do to make a click event for the user control? Thanx everyone for the help.

***Resolved*** Control's Click Event.
Hi,

Here's the question.

If I have the control's name stored in a string, can I call it's click event?

I don't want to iterate through the controls on the form and compare the names.

Is there an api call? SendMessage?

Click Event And Timer Control
Hello to all:

Being a novice at Visual Basic, I am trying to create a private sub that
will repeat or loop every 10 seconds that starts when a "Start" button is
clicked and stops when a "Stop" button is clicked. I am not sure if I need
to incorporate some kind of loop routine or can I use a timer control?

Any help would be appreciated.

Thanks,
Ken

Click Event In PictureBox Control
Hi,

I want to utilize click event on PictureBox Control. The name of the PictureBox in my code is Display1. The following is the function triggered by Click Event.

Private Sub Display1_Click()
MsgBox "Reached Here"
End Sub

This works fine. But when I open a avi in this PictureBox using mcisendstring, the function is not reached on clicking the PictureBox. What is the reason.

Thanks in advance.

[VB] Click Event On WebBrowser Control
Hello all I am using the webBrowser control on an vb 6 form and want to have a click event... basically if they click on the WebBrowser1 control it will bring the same page up in a real web browser.

regards,
Jay

Write Code For Click Event Of Command Button On A Worksheet
Hi folks,
I have used VBA in a limited way in Excel only, and have no experience with userforms, command buttons or other UI functionality. I'm trying to create a worksheet with a command button. I want the command button to call a macro when clicked.

I wrote a macro that creates a command button, places it on a worksheet, and gives it a caption. However, I can't figure out how to define the effect of the click event from within my macro. I can do this by hand in Excel (not VBA) by using the design mode of the control toolbox. But the code for the click event is attached to the worksheet, and I can't figure out how to write to that location from within my macro. I tried recording a macro to do this, but the recording doesn't capture creating the click event VBA code.

Thanks in advance for your help and happy holidays,
pwoodbury

How To Cancel The Click Event In The Image Control
I inserted image control (to make it a background for some controls) on the sheet and then I placed some controls like command after I made the image "send backward" and controls "send forward" . When I run the project the controls appear on the image. But when I click on the image the controls disappear and then appear again when I move the mouse away from the image. How to fix this problem. By the way I tried to make the propert of image, Enable= false, But it didn't success .

thank you for help.

Trying To Get A Control To Fire A Double Click Event
I have taken over the development of a control that has a MaskEdBox and a button on a user control.

On my application form I am trying to get the control to fire an event when I double click the MaskEdBox element of the control (to populate it with "todays" date). The trouble is that the MaskEdBox doesn't have a double click event to expose. I tried to use the usercontrol's dblclick event for this but, naturally, nothing happens. Is there a way of getting the MaskEdbox to inherit the event from the user control?

Does anyone have any ideas.

Handling Click Event Of Shockwave Control
I am a beginner in VB. I want to use shockwave control in VB6. But the control does not have any event like click event associated with it. I want to handle it. If anyone can help me.

Thanks in advance. Any help will be appreciated.

Click Event Not Firing From User Control
OK...I was messing around with trying to make a simple card game type program, more for fun than anything. I created a single form and a user control of type Card. I implemented manual drag and drop...and this works fine, but I'm not getting the click event to fire...any direction you could give would be appreciated.

here's the code for the main form:


VB Code:
Option Explicit Dim OffsetX As IntegerDim OffsetY As IntegerPrivate Sub aCard_MouseUp(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)    aCard(Index).Drag vbEndDragEnd Sub Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)    Source.Move X - OffsetX, Y - OffsetYEnd SubPrivate Sub aCard_Click(Index As Integer)    MsgBox "We Clicked!!"End Sub Private Sub aCard_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)    'Test    OffsetX = X    OffsetY = Y    aCard(Index).Drag vbBeginDragEnd SubPrivate Sub Form_Unload(Cancel As Integer)    Dim i As Integer        For i = Forms.Count - 1 To 0 Step -1        Unload Forms(i)    NextEnd Sub Private Sub mnu_FileExit_Click()    Unload MeEnd Sub

Here's the user control:

VB Code:
Public Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)Public Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)Public Event Click()Private Sub UserControl_Click()    RaiseEvent ClickEnd Sub Private Sub UserControl_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)    RaiseEvent MouseDown(Button, Shift, X, Y)End Sub Private Sub UserControl_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)    RaiseEvent MouseUp(Button, Shift, X, Y)End Sub

Image Control Mouse Click Event?
HIiiii

I am trying to use Image Control MouseDown and MouseUp event. It is responding for right mouse click. But not for left mouse click. Even it is not responding for Click and Double_Click event too.

What could be problem?

Hdave

Adding Click Event To Custom Control
I have a custom control that I purchased that does not have a click event. I have contacted the developer and am waiting a response. Is there a way that I can add a click event? maybe manipulate the forms click event some how? All it has is GotFocus, LostFocus, DragDrop, DragOver, and Validate events. Is the a mouse object that I can declare, something, anything??

Thanks,

Is It Possible To Disable The Double Click Event Of A Control?
I'd like the user to be able to click very quickly on a variey of controls (like labels etc) and catch the mouse up and down events (or click).

BUT, if the user clicks too quickly the double click event fires, skips the mouse down and then processors the mouse up!

so clicking 5 times very quickly on a label produces

DOWN->UP->DOUBLECLICK->UP->DOWN->UP->DOUBLECLICK->UP->DOWN->UP

instead of ....

DOWN->UP->DOWN->UP->DOWN->UP->DOWN->UP->DOWN->UP->

is there a way to kill the double click event?

Cheers?

How Can I Dynamically Call An Event (e.g. Click) For A Control ?
I dynamically created a from with about 90 controls in it. To access the controls I use a simple loop like this:


Dim el As Control

For Each el In UserForm1.Controls
  If left$(el.Name,3) = "cmd" Then

    REM Code to access standard events of the control
    
  End If
Next el


How can i acces e.g. a Click-Event? Here i cannot write cmdButton1_Click.
The control is stored in the variable el. But (of cause) el.Name_Click doesn't work.
This isn't trivial, isn't it ????

How To Kill A Double-click Event For A WMP Control
When the user double-clicks on a WMP control then the currently playing video changes to fullscreen mode. This seems to be a default behavior of the windows media control itself which I can not figure out how to turn off. As a result, is there a way to receive the double-click event for the WMP control but not allow the OS to process it ? Basically, in the myWMP1_DoubleClick event, can I somehow not allow the functioning to continue through the OS (ie: kill the event somehow?)






Edited by - uncletr on 9/27/2004 5:10:27 PM

Image Control Click Event Not Occuring?!
Hi All,

I am getting some strange behaviour with an image object.
I have some code that I run when the user clicks on an Image object but if you click quite fast... about ... I was just starting to write 'about as fast as a double-click' when it suddenly occurred to me what the problem is here!

I'll finish anyway because it might be instructive to someone else...
If you click too fast the program doesn't respond on some of the clicks (you sometimes need to click the same image up to 4 times).
As I was explaining this above I realised that the double-click event was probably being fired!... I just tested it and that is what's happening!
So now all I do is pass the event and it's index on to the standard click event and all is well!Code:Private Sub imgResponse_DblClick(Index As Integer)
    imgResponse_Click Index
End Sub

Anyway, sorry for wasting your time but I thought it was quite amusing...


Mac

Simple Error {Click Event For Image Control}
hi guys,

I have this form and I want to check if the user has clicked on a image by means of a buttons. The following is my code.
-------------------------------------------------------
Private Flag As Boolean
Private Sub Command1_Click()
If Flag = True Then
MsgBox "True" else
MsgBox "False"
End If

End Sub


Private Sub Image2_Click(Index As Integer)

If Image2(Index) = 1 Then
Flag = True
Else
Flag = False
End If
End
------------------------------------------------

Can anyone check out my mistake please

Capture Click Event Of Control Array Combobox
I have a control array combobox named PoolCombo. I am trying to capture the click event on any of the loaded ComboBoxes with:

Private Sub PoolCombo_Click(Index as Integer)
MsgBox "Got it"
End Sub

This does not seem to work, is this possible or (more likely) I am not coding it correctly. Thanks!

Why Is A Control Array Cmb Box Click Event Being Executed..... **RESOLVED **
In my application, I have 2 forms (Main Menu and New Items).

On the New Items form I dynamically build a control array of combo boxes.

When I click the New Items command button on the Main Menu, the cmb_action(0) click event gets fired after the form_load event. Why???

I only want the click event to occur once the control array has been populated and the user clicks on the control.

Thanks.

Detecting The Mouse Click Event With A Combo Box Control
Does anyone know if there is a mouse click event fired when a combo box dropdown is clicked. The click event seems to fire only when something is selected from the dropdowm list. But if nothing is selected the event appears not to happen.

I need a way to detect the click event even if nothing is selected or no changes are made to the selection.

Can anyone help?

Urgent! Double Click Event In DataGrid Control
I want to Select a row in DataGrid Control while the Double Click Event happend ! Can you help Me ?

How Handle Click Event On Link In Webbrowser Control?
How handle click event on link in webbrowser control?

I use webbrowser control in VB. I want handle click on link.

Image Click Event Stops Imagelist Control From Updating
Using Excel VBA

I cannot work out why the following is happening:

I have a form that is populated from the contents of a spreadsheet, with each row being read using a For Next Loop.
In addition to the form containing textboxes, buttons and labels it also has an imagelist control.
A mousemove event is linked to the image and this functions correctly (displays a form with an imagelist control and linked image). If I change the image event to anything else e.g. mousedown, click, doubleclick etc and run the same code as a result of this event I get a situation whereby the next line that is read from the spreadsheet updates the textboxes and labels but not the image (imagelist linked), the picture remains at the previous image. However If I click the image it displays the correct larger picture and when that form is closed the imagelist on the main form is updated correctly.
It appears that the image click procedure is stopping the variables being updated for the imagelist control until the sub form has been closed, yet using the same code I get no problems with mousemove event.

An example of the code is as follows:

Code:
For counter = 7 To 27
        Image1.Picture = ImageList1.ListImages(counter - 6).Picture
        pic_label1.Caption = Worksheets("Sheet2").Cells(counter, 4) & " - " & Worksheets("Sheet2").Cells(counter, 5)
        .........
Next

'Private Sub Image1_Click() ---------------------------------------- code causes imagelist control to stop updated
'image2show = counter - 6
'imageshow.Caption = Worksheets("Sheet2").Cells(counter, 4) & " - " & Worksheets("Sheet2").Cells(counter, 5)
'imageshow.Show
'End Sub

----------- code works ok
Private Sub Image1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
image2show = counter - 6
imageshow.Caption = Worksheets("Sheet2").Cells(counter, 4) & " - " & Worksheets("Sheet2").Cells(counter, 5)
imageshow.Show
End Sub

Private Sub UserForm_Activate()
Me.Caption = Worksheets("Sheet2").Cells(image2show + 6, 4) & " - " & Worksheets("Sheet2").Cells(image2show + 6, 5)
        image2.Picture = ImageList2.ListImages(image2show).Picture
        
End Sub

Save Image Code Not Working Properly, (code Included)
I am trying to download an image file using DownloadFile and for whatever reason it's not downloading the file... I can make the image source link display... so I know that's working. It just isn't saving the file, this code used to work but not anymore apparently.

Anyone? Thanks!


VB Code:
Public Function DownloadFile(URL As String, LocalFilename As String) As Boolean    Dim lngRetVal As Long    lngRetVal = URLDownloadToFile(0, URL, LocalFilename, 0, 0)    If lngRetVal = 0 Then DownloadFile = TrueEnd Function Dim IMG As HTMLImgDim HTML As HTMLDocumentSet HTML = WebBrowser1.DocumentFor Each IMG In HTML.imagesIf InStr(IMG.src, "IMAGEKEYWORD") ThenDownloadFile IMG.src, App.Path & "image.jpg"Exit ForEnd IfNext

How To Detect A Click Event On Embeded Image Inside An Activex Control.
Hello All,

I need some help figuring this out. I am developing an ActiveX control that contain an array of multiple image boxes embedded inside a windowless transparent form (container). Based on property settings at design time, only one imagebox is visible, and all others are set to be invisible. I have a method (property) set in the control that decides which image is going to be visible. This is settable during a standard VB exe project development, and at run time via user selction. When I compile the OCX and use it to on a standard VB EXE project, I don't have an option available to write code for an Image click event. Only events available are control got focus, & lost focus etc. How do I go about adding the Image click event (to the Visible Image) inside my control?

Do I have to implement another method/event within my Activex control? If I did that, how would I then pass the name of the caller (name of the form where the control click was initiated) in to my activex event, and have the activex report back to the "SAME" calling form during run time?

Thanks

Can Someone Help (code Included)
Hi, Im trying to access a database through vb and then import the results into a flash file, everything is working great except that i cant figure out how to do the next and previous records (10 at a time)

Here is my code below,
any help would be greatly appreciated


'beginning of code





Option Explicit

Public cnn As Connection 'connection to the database
Public rcst As Recordset 'data keeper



Private Sub cmdConnect_Click()
'connects to the database

Dim strCnn As String 'connection string
Dim intErr As Integer 'iteration var

On Error GoTo er

'every connection needs connection string:
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & " est.mdb" & ";"

Set cnn = New Connection 'create new connection
cnn.ConnectionString = strCnn 'specify the connection string
cnn.Open 'open the connection
frmData.Caption = "Data Access - Connected"
cmdDisconnect.Enabled = True
cmdConnect.Enabled = False
Exit Sub
er:
If cnn.Errors.Count > 0 Then 'process all connection errors
For intErr = 0 To cnn.Errors.Count - 1
MsgBox "Error in Connection: " & cnn.Errors(intErr).Description, vbCritical, "Error"
Next intErr
Else 'process other errors
MsgBox "Error in cmdConnect", vbCritical, "Error"
End If
End Sub

Private Sub cmdDisconnect_Click()
On Error Resume Next
cnn.Close 'try to close the connection
Set cnn = Nothing 'clear the object
Set rcst = Nothing 'clear the recordset if it was init before
frmData.Caption = "Data Access - Disconnected"
cmdDisconnect.Enabled = False
cmdConnect.Enabled = True
End Sub




Private Sub xWin_FSCommand(ByVal command As String, ByVal args As String)



If command = "databox.getrecords" Then

Static recordnumber As Integer 'iteration var
'gets the First_Name field from the main table
Dim strSql As String ' use SQL syntax to obtain info
Dim flashtext As String ' use SQL syntax to obtain info
'recordnumber = 1

'check if connection was established
If cnn Is Nothing Then Exit Sub
If cnn.State = 0 Then Exit Sub

'sql statement that selects First_Name column from Main table
strSql = "SELECT First_Name FROM Main"

Set rcst = New Recordset 'recorset that will contain the data
rcst.CursorLocation = adUseClient
rcst.Open strSql, cnn 'gets the data

xWin.SetVariable "recordcount", "recordcount =" & rcst.RecordCount 'put records into flash
'output the info



''Form Level
Dim i As Integer
Static textboxrotation As Integer


''In Form_Load

i = 1

''In Button's _Click Event
Do While Not rcst.EOF 'check for the end
flashtext = rcst.Fields(0).Value
xWin.SetVariable "r" & i, flashtext
recordnumber = recordnumber + 1
rcst.MoveNext 'goto the next record
i = i + 1
''Divide it by 10, If the remainder is zero, then exit the sub
''and wait for the user to click again..
If recordnumber Mod 5 = 0 Then
Exit Do
Else
rcst.MoveNext



End If

Loop


rcst.Close
Set rcst = Nothing 'release the memory

End If


End Sub

Private Sub Form_Load()

'flash movie
frmData.ScaleMode = 3
xWin.Movie = App.Path & "Bounce.swf"
xWin.Left = 0
xWin.Top = 0
xWin.Width = 640
xWin.Height = 480
xWin.Play



Dim strCnn As String 'connection string
Dim intErr As Integer 'iteration var

On Error GoTo er

'every connection needs connection string:
strCnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & " est.mdb" & ";"

Set cnn = New Connection 'create new connection
cnn.ConnectionString = strCnn 'specify the connection string
cnn.Open 'open the connection
frmData.Caption = "Data Access - Connected"
cmdDisconnect.Enabled = True
cmdConnect.Enabled = False
Exit Sub
er:
If cnn.Errors.Count > 0 Then 'process all connection errors
For intErr = 0 To cnn.Errors.Count - 1
MsgBox "Error in Connection: " & cnn.Errors(intErr).Description, vbCritical, "Error"
Next intErr
Else 'process other errors
MsgBox "Error in cmdConnect", vbCritical, "Error"
End If



End Sub

Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
Set cnn = Nothing 'destroy object (prevent memory leaks)
Set rcst = Nothing
End Sub



'end of code



thanks

Help Please Code Included
I have attached a small program that is showing what I am trying to do. There is a readme that explains better, but an overview is I am trying to read a text file that has these type of data:

Type = 458093485

I need to return just the number in a text box. Someone gave me some code (here at VBForum) but I cant get it to display so if someone could take a look I would appreciate it....

TIA

Spiritwolf

Subscript Out Of Range :( (code Included)
Hey all. I'm working on this map editor, currently modding in old map/terraforming code into it, but I'm getting a substript out of range. Here's a link to my code: http://geocities.com/rm2k_palace/Help.zip

Run it, and you'll see what I'm talking about

Thanks a lot!

-Chris

Need Help With Winsock Issue... Code Included
I've made a very simple program to test how the winsock works.
I'm getting pretty much half of it working. I get an error on my 2nd PC(Win98 OS) with "Run-time error '126'."
Here's the stats:

-Program created from VB6 on XPpro
-XPpro side (Remotehost = 192.168.1.3, Remoteport = 90, Bind = 92)
-Win98 side (Remotehost = 192.168.1.2, Remoteport = 92, Bind = 90)
-Using UDP
-I can get the XPpro to send my text typed to Win98, and my program on Win98 side receives and views text in the program. When I try to type text from Win98, I get the Run-time error.
I can't find why. Is there something with win98 causing this issue? (Code at bottom)

Any comments are welcomed, please.

Drummingsticks

Code below:

Code:
Option Explicit

Private Sub cmdConnect_Click()
' The control's name is udpPeerB.
With udpPeerSA
' IMPORTANT: be sure to change the RemoteHost
' value to the name of your computer.
.RemoteHost = txtIP.Text
.RemotePort = Val(txtRmtHost.Text) ' Port to connect to.
.Bind Val(txtBind.Text) ' Bind to the local port.
End With
End Sub

Private Sub Form_Load()
'' The control's name is udpPeerB.
'With udpPeerSA
'' IMPORTANT: be sure to change the RemoteHost
'' value to the name of your computer.
'.RemoteHost = "192.168.1.3"
'.RemotePort = 1001 ' Port to connect to.
'.Bind 1001 ' Bind to the local port.
'End With
End Sub

Private Sub txtSend_Change()
' Send text as soon as it's typed.
udpPeerSA.SendData txtSend.Text
End Sub

Private Sub udpPeerSA_DataArrival _
(ByVal bytesTotal As Long)
Dim strData As String
udpPeerSA.GetData strData
txtOutput.Text = strData
End Sub

Listview Problem - Code Included
After running the public sub below the last item in the left listview (lvwLeft) is selected. Anyone know why?

Thanks,
Bernie


Code:
Public Sub SubSyncSelect()
On Error Resume Next
Dim MatchLeftFile As ListItem
For Each MatchLeftFile In lvwLeft.ListItems
If MatchLeftFile.Selected = True Then
FileSource = frmMainMatch.dirLeft.Path & "" & MatchLeftFile
FileTarget = frmMainMatch.dirRight.Path & "" & MatchLeftFile
frmMainMatch.axsFileInfo1.FileName = FileSource
Set itm1 = frmMainMatch.lvwLeft.FindItem(MatchLeftFile, , , lvwWhole)
itm1.Bold = True
itm1.SmallIcon = "equals"
itm1.ForeColor = vbBlue
itm1.ListSubItems.Add (1), , frmMainMatch.axsFileInfo1.ModifiedDate
itm1.ListSubItems(1).ForeColor = vbBlue
itm1.ListSubItems(1).Bold = True
itm1.ListSubItems.Add (2), , frmMainMatch.axsFileInfo1.ModifiedTime
itm1.ListSubItems(2).ForeColor = vbBlue
itm1.ListSubItems(2).Bold = True
Set itm2 = frmMainMatch.lvwRight.FindItem(MatchLeftFile, , , lvwWhole)
If itm2 = "" Then
Set itm2 = frmMainMatch.lvwRight.ListItems.Add(, , MatchLeftFile)
FileCopy FileSource, FileTarget
End If
itm2.Bold = True
itm2.SmallIcon = "equals"
itm2.ForeColor = vbBlue
itm2.ListSubItems.Add (1), , frmMainMatch.axsFileInfo1.ModifiedDate
itm2.ListSubItems(1).ForeColor = vbBlue
itm2.ListSubItems(1).Bold = True
itm2.ListSubItems.Add (2), , frmMainMatch.axsFileInfo1.ModifiedTime
itm2.ListSubItems(2).ForeColor = vbBlue
itm2.ListSubItems(2).Bold = True
End If
Next
end sub

Problem With Strings, Code Included
i need to get information from different records in one record.
There are some restrictions:
the first character of the record must be the same
the second until the 21st character must be the same
the information i have to put together starts from position 33
the startposition of this information may never be the same.
i.e.:
0800100
0800100
In the attachement you will find the begin situation and the desired situation.


This is the code i'v made this far:

Sub Main()
Dim i As Integer

sOldfile1 = "c:floreacflores2.txt"
sFile2 = "c:floreacflores2.dat"
Open sOldfile1 For Input As #1
Open sFile2 For Output As #2

Line Input #1, sstring
sTOREString = sstring
Do While Not EOF(1) ' Check for end of file.

Line Input #1, sstring

strTempstring = Mid(sTOREString, 22, 61)
strTempstring2 = Mid(sstring, 22, 61)
lengte1 = Len(RTrim(strTempstring))
lengte2 = Len(RTrim(strTempstring2))

If (Left(sTOREString, 15) = Left(sstring, 15)) Then
If (Mid(sTOREString, 16, 6) = Mid(sstring, 16, 6)) Then
If (Left(sTOREString, 1) = Left(sstring, 1)) Then
If (lengte1 <> lengte2) Then

header = Mid(sTOREString, 2, 20)
links = RTrim(strTempstring)
rechts = LTrim(strTempstring2)
sTOREString = header & links & rechts
Debug.Print sTOREString

End If
End If
Else
Print #2, sTOREString
sTOREString = sstring
End If

End If


Loop


Close #1
Close #2



End Sub

Problem With Code. Included Source 4 U
Hi there..
I'm writing a program in VB to email people including attachments. Anyway.. My problem is.. that the program does not email the user. I've noticed that when i connect with outlook and then try again with my program, the email works.. Weird huh.... i cant figure it out.. I've included the dll as well as a sample code. If anyone can find out why this is the case please reply.. Thanks in advance

Jason

How Can I Click A Button In A Toolbar Control By Code?
Hi, I need to click a button of a button group (so it remind down) on a toolbar control using code, I can't find how to do this. help anyone..

Is This Included In The VB CONTROL???
hi guys, im just wondering, is this part of the vb control??? if so, how do i include it??? thank you..
(please see attachment)

Clipboard - Code Included - Help With Assigning Keys
I've got a program that copies multiple items from the clipboard, at the moment it stores the items to a listbox. Can anyone tell me how to assign the items added to a hotkey, for example when a new item is copied from the clipboard a hotkey is assigned CTRL-1 then when another is copied that gets assigned CTRL-2, or something similar.

Heres the code,

thanks! any suggestions appreciated.

Private StrArList(10) As String 'Used to help keep the latest clipboard entry at the top of the list. _
it's harder to do it with the list alone so we will have to use an array

Private Const CTAError = -1 ' used to report that the array organizing has reported an error.
Private Const CTASuccess = 0 ' used to report that the array organizing has success
Private previousclip As String 'keep track of the previous clip so we can know when our clip has been changed

Private Function pathway()
Dim paths As String
paths = App.Path 'we need the app path
If Right$(paths, 1) <> "" Then paths = paths & "" 'if the program is located in the root directory _
we will not need a () how ever if it's located in a folder we will need a () so we check the end of _
the directory to see if there is a () if not add one..
pathway = paths
End Function

Private Sub recordlog()
On Error GoTo logerror

Open paths & "cliph.log" For Binary As #1
Put #1, , StrArList 'print log
Close #1

Exit Sub

logerror:
'if an error in writing log, report it and turn off the logging feature to prevent _
unneeded program shutdown

MsgBox "There was an Error in recording log: " & vbCrLf & Err.Description & vbCrLf & "As a result the logging feature has been turned off"
mnuRecordLog.Checked = False
Resume Next
End Sub
Private Function ARNULL(ByVal index As String) As Boolean

If StrArList(index) <> "" Then
ARNULL = False
Else
ARNULL = True
End If

End Function
Private Sub updatelist()
lstCLips.Clear
For i = 0 To 10
If Not ARNULL(i) Then lstCLips.AddItem StrArList(i) 'check to see if the list item is empty _
if it isn't add it to the list. only the items after the last entry should be empty.
Next i

End Sub


Private Function CompileToArray()
On Error GoTo CTAERR
'make space at the beginning of the array for the next entry.
For i = 10 To 1 Step -1
StrArList(i) = StrArList(i - 1)
Next i

CompileToArray = CTASuccess 'success even though no errors should go wrong whiles _
writing to arrays

StrArList(0) = Clipboard.GetText ' set the latest entry on the newly cleared part of the list
previousclip = StrArList(0) 'set the previous clip so we'd know if we have new changes
Exit Function

CTAERR:
CompileToArray = CTAError 'report an error
MsgBox "error: failure to record"

End Function

Private Sub Exit_Click()
End
End Sub

Private Sub Form_Load()
'get the current item on the clipboard
If Trim(Clipboard.GetText) <> "" Then
CompileToArray
updatelist
End If
End Sub

Private Sub lstCLips_Click()
'when the user clicks on an item display it's contents as is in the text box
i = lstCLips.ListIndex
Text1.Text = StrArList(i)
End Sub

Private Sub lstCLips_DblClick()

If lstCLips.ListIndex < 1 Then Exit Sub
continues = MsgBox("Are you sure you want to reset this clip?", vbYesNo) ' Make sure the user _
intended to set one of his/her contents as the active contents

If continutes = vbYes Then Clipboard.SetText lstCLips.List(lstCLips.ListIndex) 'set the previous content as the new
End Sub

Private Sub mnuclearall_Click()
'reset everything
Clipboard.SetText ""
Erase StrArList
lstCLips.Clear

End Sub

Private Sub mnuRecordLog_Click()
'check and uncheck the mnuRecord
If mnuRecordLog.Checked = False Then
mnuRecordLog.Checked = True
Else: mnuRecordLog.Checked = False
End If
End Sub

Private Sub Timer1_Timer()
Dim strcontents As String
strcontents = Clipboard.GetText 'get the text data
If strcontents = previousclip Then Exit Sub ' and check to see if it's the same as the _
previous clip data
If Trim(strcontents) <> "" Then 'make sure it's not blank, we can't have no blank entries in the clipboard _
recorded here because it will corrupt the array and list relationship


If CompileToArray = CTAError Then Exit Sub 'if an error whiles organizing the array then don't execute
updatelist 'other wise update the list box
If mnuRecordLog.Checked Then recordlog 'and record the log if selected.
End If

End Sub

Parsing Information From Links (example Code Included)
I have this code of which I use to collect specific links off of a page -


VB Code:
Dim lnk As HTMLLinkElementFor Each lnk In WebBrowser1.Document.linksIf InStr(lnk, "/abc/") Or InStr(lnk, "/def/") ThenList1.AddItem lnkEnd IfNext


When it's done, List1 will have 100 links that look like this:

http://www.site.com/site/235234234.html

Instead of grabbing the entire link (like im doing with the above code) how can I make it only grab a PART of the link: 235234234.html

I assume I specify text BEFORE the wanted text and AFTER the text right? The BETWEEN text is what will be added to the list.

Something like this? -


<a href="http://www.site.com/site/235234234.html">

BEFORE: /site/ AFTER: >


I'm kind of clueless actually. Thanks!

Passing An Array Value From A Procedure [code Included]
I have a slight problem that I've been bashing my head over for the past 3 hours that I can't seem for the life of me to get a solution for. What I'm doing is quite simple. I have 3 sections setup (Listbox, Label and Command button; listbox, lbl1, cmd1 respectfully.). Now I have a procedure setup so I can open a file, read it's contents and send the file contents to a list box (listbox). I'll explain more after the code is printed :

VB Code:
Public Sub form_load() End Sub  Private Sub testarray(miscarray() As String) Dim number As Integernumber = 0If listbox.ListCount = 0 Then Open ("first.txt") For Input As 1Do Until (EOF(1) = True)    Input #1, miscarray(number)    listbox.AddItem miscarray(number)    number = number + 1LoopClose #1End If End Sub  Public Sub cmd_click()Dim z(10) As StringCall testarray(z)lbl1.Caption = miscarray(4)   End Sub



Now I know this looks like a mess (sorry) but the coding is easy to read. I want the procedure testarray to run when the button is pressed (hence the call function). However, in it, I also want to be able to read the arrays in another procedure (Hence me testing it out with lbl1.caption = miscarray(4) )

But it seems that I get a compiling error when I try this : "Sub or function not defined" and it highlights miscarray(4).

How could I achieve the passing of the variable so I can use the procedure's contents? If anyone could point me in the right direction? Thanks so much in advance!

Copyright © 2005-08 www.BigResource.com, All rights reserved