|
Hi, I found this might help you. In vb6 create a text box and go to event KeyDown. See the following code then you will get some idea from it.
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)<br />
<br />
MsgBox KeyCode<br />
<br />
End Sub
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
I have some buttons in my form, so I had to make a roundabout way to solve the problem with the capturing of the arrow keys. First, I created a text box and place it behind a button (so the text box isn't visible but has the focus!); and second - I set the TabIndex property of the text box to 0, so when I press an arrow key, the KeyDown event of the text box will be executed (not the changing of the focus).
I wonder why in VB there isn't a way/property to turn off the focus changing when an arrow key is pressed, so the programmer can capture this event directly (by analogy with the TabStop property).
Thanks for the idea, Roath
|
|
|
|
|
Why you have to put textbox behind the command button? If you want to move from the first command to the other command button just set Tab Order property of each command button. We don't need to use text box behind the command button and it is very easy that you do not need to write the code.
Anyway, my name is Kanel not Roath. (Cambodia use Family name then First name style).
Roath Kanel
APO-CEDC
Save Children Norway-Cambodia Office
|
|
|
|
|
My New User form has a pair of text boxes used to define new users to my app. For both I've used the 'Leave' event to validate them before the form's OK button is enabled. (I've included the code for the simpler one of the two below.) I also want a Cancel button so that the user can choose not to set up a new user. At the mo, the Cancel button just sets DialogResult.Cancel.
When the user clicks on the Cancel button the first time, the Leave event is still triggered and the users gets a "You must enter a name." message box. If the user clicks Cancel again, the window closes.
I realise that I could do the checks when the user clicks OK but it seems 'more OO' to validate each box. How can I avoid this message box on cancel but still check the formatting when the user moves out of the text box otherwise?
Private Sub txtNewOppName_Leave(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles txtNewOppName.Leave
If txtNewOppName.Text = "" Then
Me.NameDefined = False
MessageBox.Show("You must enter a name.")
Me.Select()
Else
Me.NameDefined = True
End If
If Me.EmailDefined And Me.NameDefined Then
Me.btnOk.Enabled = True
End If
End Sub
|
|
|
|
|
How do I set a reference to the Microsof.Win32 Namespace? I've been looking for it both in the Add Reference List and in the GAC and I haven't found it. Where?
|
|
|
|
|
I'm a newbie so maybe this is a daft question but why do you need to? If you just put
Imports Microsoft.Win32
at the top of your class, does that do the trick?
|
|
|
|
|
How to get the target path of shortcut files(.lnk)?
|
|
|
|
|
I'm trying to read text and maybe pixels from a windows application. The application has list boxes and a text box. I tried an example i found using WM_GETTEXT, which works for some applications like Notepad (textbox Edit), and the windows calculator, but when I probed for the class name of the progam i'm trying to read from, it says #32770, and the same WM_GETTEXT trick doesn't work.
Does anyone have advice for what I should try?
|
|
|
|
|
I used spy++ to find out that the text I want is sent through messages like this:
EM_REPLACESEL lpszReplace:0012f050("Text I want to scrape")
|
|
|
|
|
I made a little application that grabs random pixels from a scanned photo and figures out the R, G, & B values of that pixel. Then it's supposed to trasfer those values found into one of three other PictureBox controls. one for red, one for green and one for blue. I used this formula:
lColor = picPhoto.Point(x,y)<br />
iRed = lColor Mod 256<br />
iGrn = lColor \ 256 Mod 256<br />
iBlu = lColor \ 65536 Mod 256<br />
<br />
picRed.pset (x,y),RGB(iRed,iRed,iRed)<br />
picGrn.pset (x,y),RGB(iGrn,iGrn,iGrn)<br />
picBlu.pset (x,y),RGB(iBlu,iBlu,iBlu)
The Mysterious problem is that only the blue channel is doing what it's supposed to, producing a nice greyscale rendering of the blue channel pixels in question. The other two just produce noise. I can't figure out why. I checked and double checked all the properties of the PictureBox controls, and they're exactly the same. I also double checked the formula for separating the iRed, iGrn, and iBlu factors from the lColor value.
Any thoughts? Try it for yourself, see if you can get it to work. What am i doing wrong?
----------------------------------
Okay. I figured it out. The problem was the computation of the x,y coordinates for the red and green windows. It was computing the right colors, but it was putting them in the wrong places. It works now. Thanks.
"Go to, I’ll no more on’t; it hath made me mad." - Hamlet
|
|
|
|
|
Your math is a little off. Here's a working example:
Private Sub mnuSplit_Click()
Dim x, y As Long
Dim RGBColor As Long
Dim R, G, B As Long
Debug.Print "Image Height: " & pctSource.Height
Debug.Print "Image Width : " & pctSource.Width
For y = 0 To pctSource.Height
For x = 0 To pctSource.Width
RGBColor = pctSource.Point(x, y)
R = GetRGB(RGBColor, 1)
G = GetRGB(RGBColor, 2)
B = GetRGB(RGBColor, 3)
pctRed.PSet (x, y), R
pctGreen.PSet (x, y), G * 256
pctBlue.PSet (x, y), B * 65536
DoEvents
Next
Next
End Sub
Function GetRGB(RGBval As Long, Num As Integer) As Integer
' Pass in Num = 1 to return the Red value, 2 for Green, and 3 for Blue
GetRGB = RGBval \ 256 ^ (Num - 1) And 255
End Function
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Nope. That didn't do it. The problem is somewhere else. I applied your code to it and it's doing the exact same thing.
I'm pretty sure your math formula and mine are outputting the same results. I'll try stepping through it yet again to see if I can find the solution that way.
Thanks for your help, and let me know if you think of anything else.
"Go to, I’ll no more on’t; it hath made me mad." - Hamlet
|
|
|
|
|
Funny, that exact code works perfectly on mine. I can send you the project if you want, but theres nothing more to it than buttons and 4 PictureBoxes. What color depth do you have your video card set at? When you use the PictureBox Point and PSet methods, you're not getting the color depth of the image, you're getting the color depth of the screen it's displayed on. The code will work with 32 and 24 bit colors depths only.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Actually I figured out the problem. I edited my original post with the answer. It was a problem with the x,y coordinates rather than the color or the pixels. It was finding the right colors but putting them in the wrong places. Hence the noise.
Thanks for your help.
"Go to, I’ll no more on’t; it hath made me mad." - Hamlet
|
|
|
|
|
I've completed an application and was trying to run it in another unit with JIT debugging enabled. It showed me the following error:
JIT Debugging failed with the following error:0x800405a6
I've searched for the documentation on this and it tells me the that:
This error occurs if you attempt to do Just-In-Time debugging on a machine where there is no user logged onto the console. As a result, there is no session in which to display the Just-In-Time debugging dialog box.
Even though I was logged in the machine and I had Debugger Users Privilege. Anybody encountered this before?
|
|
|
|
|
Knowing only an interface, how do I enumerate all the classes in a local machine that implement that particular interface? Do I have to register all the implementers in the local machine's GAC?
|
|
|
|
|
Hi friends
In my SQL query I have like this
Str = "ame's account"
Qr= "select * from Tab where fld='" & Str & "'"
Because of the 's in the where clause string its showing syntax error how to solve this
Any clarification let you know,
Thanks
Shan
|
|
|
|
|
Shanmukeswara Rao wrote:
Str = "ame's account"
Qr= "select * from Tab where fld='" & Str & "'"
I have had this same problem before. You should use parameters in your query. Combining the strings like this is prone to a SQL injection attack also. The way you use a parameter query depends on if you are using MS SQL or ODBC (MS Access) for your database. If you provide more information or more sample of your code I can show you better.
Laterness...
Doug
|
|
|
|
|
My Database is MSAccess,
Earlier I used to solve once this, concatenated with ` symbol before and after the string, now it is not working.
Thanks
Shan
|
|
|
|
|
Str = "ame's account"
Qr = "select * from Tab where fld=?"
Dim cmd As OdbcCommand = New OdbcCommand(Qr, OdbcConnection1)
Dim param1 as OdbcParameter = New OdbcParameter("name", OdbcType.VarChar)
param1.Value = Str
cmd.Parameters.Add(param1)
then execute the command...
Dim dr As OdbcDataReader = cmd.ExecuteReader()
Laterness...
Doug
|
|
|
|
|
You could try checking your strings with this code to eliminate SQL Injection:
<br />
str=replace("ame's account","'","''")<br />
This will replace the single quotation with a double quotation, which is interpreted by SQL parsers as a literal single quotation mark. This would somewhat prevent SQL Injection.
|
|
|
|
|
Nice try, but it won't eliminate any injection attacks. The attack merely has to include his code between two single quotes marks to defeat your method.
The better way, and the most recommended way BY FAR, is to use parameterized queries. The parameter objects look for known injection techniques and takes care of all your argument escaping for you. String concantenation is most definately a poor technique to use with queries.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Regarding the safety of str=replace("ame's account","'","''") , I think it is relatively safe. Whatever way you want to swing it, there is no way that a user can insert a ' that will not be escaped.
my blog
|
|
|
|
|
Just escaping the ' was not the point. The technique was billed as a method to prevent SQL injection attacks, and it's not...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Sorry to split hairs Dave, but...your advice is good, but your facts are wrong.
If you escape every string value in every SQL string that you construct, (and also take care to sanitize all numeric values), then you are in fact safe from SQL injection.
The problem with the escaping approach is that it is difficult to apply consistently. For example, most programmers will neglect to escape values that they obtain from cookies, or the session, or the database. That is a mistake, because users can often affect that data too.
my blog
|
|
|
|