|
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
|
|
|
|
|
PAguilar09 wrote: ascii = 13 & ascii = 8
How can the same variable have two different values ?
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.
|
|
|
|
|
I guess you would be better off using textchanged event for checking the textbox text instead of Keypress since those will not fire if copy/paste anything in your textbox through mouse.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
You can do the following:
Imports Microsoft.VisualBasic ' at the begining of your .vb file
If Char.IsNumber(e.KeyChar) Or e.KeyChar=ChrW(Keys.Return) Or e.KeyChar=ChrW(Keys.Back) Then
e.Handled = False
Else
' etcetera
End If
Best regards,
Jaime.
|
|
|
|
|
THANKS JAIME UR CODE WORKED PERFECTLY!!!
|
|
|
|
|
Best regards,
Jaime.
|
|
|
|
|
A better bet is Char.IsNumber or Char.IsControl
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.
|
|
|
|
|
Nope. It wont be. The user will be able to copy/paste anything in the textbox that way. I hope you meant this:
if(!char.IsControl(e.KeyChar) && !char.IsNumber(e.KeyChar)){
e.Handled = true;
}
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Yes, that is what I meant. I just meant to use IsControl instead of checking for specific control characters.
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.
|
|
|
|
|
User can still copy paste anything via mouse.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Something else to note... the way your code currently is, someone could key in 20 digits, then accidentally hit the A key and it will delete the 20 digits previously entered because of this line:
PAguilar09 wrote: txtAns.Clear()
Is that really what you are wanting to do?
|
|
|
|
|
_Damian S_ wrote: Is that really what you are wanting to do?
I would. Make them do it right first time
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|