|
Hello everyone
I am sure this is somting simple but i cant figuer it out
how you can you have a button click a button ???
say
when you click button 1 it will be like clicking button 2 button 3 at the same time ??
Thanks
Bob
|
|
|
|
|
Just call them;
Private Sub Button1_Click(sender As Object, e As EventArgs)
Button2_Click(Nothing, EventArgs.Empty)
Button3_Click(Nothing, EventArgs.Empty)
End Sub
I are Troll
|
|
|
|
|
Why not have a single handler for all the buttons? Then you can wisely put some conditions so that only a particular code is fired depending on the button clicked.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
I like Danish's method
Private Sub ClickAllButtons(sender As Object) Handles Button1.Click, _
Button2.Click, Button3.Click
Dim btn As Button = Nothing
If TypeOf sender Is Button Then
btn = DirectCast(sender, Button)
If btn.Name = "Button1" Then
callButton1Stuff()
callButton2Stuff()
callButton3Stuff()
ElseIf btn.Name = "Button2" Then
callButton2Stuff()
Else
callButton3Stuff()
End
Else
' Maybe a good idea to do something here.
Exit Sub
End
I don't speak Idiot - please talk slowly and clearly
'This space for rent'
Driven to the arms of Heineken by the wife
|
|
|
|
|
Right on guys thanks a lot
|
|
|
|
|
|
You should have posted it in General database[^] forum.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Hello,
I am programming in VB2005.
I have a Form1 and Class A:
a) In Form1, I have a Picturebox (Name=PictureBox1)
b) Class A inherits from PictureBox
I am trying the following but the Picturebox1 does not display anything:
Dim MyA As New A(PictureBox1.Width, PictureBox1.Height)
MyA.Location = New System.Drawing.Point(150, 150)
MyA.BackColor = Color.Red
PictureBox1 = MyA
Why doesn't it works?
I have an alternative to solve the problem but I would like to understood the problem above.
Alternative sdolution:
Dim MyA As New A(500, 350)
MyA.Location = New System.Drawing.Point(150, 150)
MyA.BackColor = Color.Red
controls.add(MyA)
Shay Noy
|
|
|
|
|
shaynoy wrote: In Form1, I have a Picturebox (Name=PictureBox1)
Why don't you use real variable names ?
shaynoy wrote:
Dim MyA As New A(PictureBox1.Width, PictureBox1.Height)
MyA.Location = New System.Drawing.Point(150, 150)
MyA.BackColor = Color.Red
PictureBox1 = MyA
This is a bit dumb. What you need to do, is either change your picturebox to be a ClassA, or you need to just create a picturebox and add it to the Controls collection of the form.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
This is a bit dumb. What you need to do, is either change your picturebox to be a ClassA,
My ClassA inherits from PictureBox object.
Now my form1 is creating a new instance of class A and this new instance will "return" a PictureBox that I would like to display on my form1. So I though to do the following form1.PictureBox1=NewInstanceOfClassA to display the result of new instance of ClassA to my form1.
...or you need to just create a picturebox and add it to the Controls collection of the form.
WHay to add it if already exists in my form1, I only want to overwrite it with my new instance of class A
Thank you
Shay Noy
|
|
|
|
|
shaynoy wrote: I have an alternative to solve the problem but I would like to understood the problem above.
Start by highlighting the differences between the first and the second code. What does controls.Add do?
I are Troll
|
|
|
|
|
In the first code PictureBox alrady exists so I do not have to add it.
In the second code PictureBox doesn't exist so I am adding it at run-time.
So what now?
Shay Noy
|
|
|
|
|
shaynoy wrote: In the first code PictureBox alrady exists so I do not have to add it.
PictureBox1 = MyA This would not 'replace' the PictureBox1 in memory with an MyA, and I don't know whether the property is smart enough to add the control to the controls-collection on it's own.
I are Troll
|
|
|
|
|
Thank you, so you suggest to use controls.add, don't you
Shay Noy
|
|
|
|
|
That's not what I'm suggesting; you asked merely why the first version didn't work as you expected it to.
I guess that you want to replace that pictureBox1 with a ClassA . Delete the PictureBox from the Form and drop a ClassA on it
I are Troll
|
|
|
|
|
What do you mean when you say drop?
Shay Noy
|
|
|
|
|
I meant dragging a ClassA-item from your Toolbox to the Form; just like you add any other control to the form
I are Troll
|
|
|
|
|
Thank you for the tip
Shay Noy
|
|
|
|
|
Hi,
I'm connecting client to server using VB6 Winsock Controls
'==========Serverside============================
Winsock1.Protocol = sckTCPProtocol
Winsock1.RemoteHost = strParm(0)
Winsock1.RemotePort = 1002
Pause (7)
MsgBox "Before Connecting" 'just to do something, and give time to establish connection
Winsock1.Connect
MsgBox "After Connecting"
DoEvents
'Delay2 = 1
Pause (10)
'Winsock1.SendData ("Starting dropship refresh...")
It works fine with the MsgBox between the Connect and the Senddata, but without it gives an error when firing Senddata method, seems because connection is not established quick enough.
Please help, how can I ensure connection before sending data?
I have tried some 'delay' processes which works 1 minute and doesnt the next.
Thanks in advance
P
|
|
|
|
|
Why are you using VB6 ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
This is an enhancement to an existing big VB6 system. i'm just addind this bit.
P
|
|
|
|
|
|
Hi i am currently using this following code to test if the user enters in anything else besides numeric values:
I am having trouble because if I try to use the enter key or backspace key it also views it as a alphanumeric character and will display the error message but I WANT TO ALLOW THE ENTER AND BACKSPACE KEY any SUGGESTIONS?
Private Sub txtAns_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtAns.KeyPress
'*************************************************************************************
'in this subroutine when the user clicks on the text box to enter in his/her numeric value
'I will test for numeric validation and if the user tries to enter anything other then a number
'an error message will be displayed.
'*************************************************************************************
' textbox1 just accept numeric data
If Char.IsNumber(e.KeyChar) Then
e.Handled = False
Else
'numeric value has not been entered so display appropriate error msg and allow user to try again
MessageBox.Show("Please Enter Numbers Only")
txtAns.Clear()
e.Handled = True
End If
End Sub
|
|
|
|
|
Why not use a NumericUpDown control instead?
Anyways, in your code, just add a check if the KeyChar value is equal to that for enter and delete key.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
So would this be correct syntax??? in VB.NET
If Char.IsNumber(e.KeyChar) & ascii = 13 & ascii = 8 Then
e.Handled = False
Else
|
|
|
|