|
Google the keypress event... I found this when I did:
MSDN function you use[^]
There are plenty of code examples out there!
|
|
|
|
|
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.F1 Then
Form2.Show()
ElseIf e.KeyCode = Keys.F2 Then
Form3.Show()
End If
End Sub
Is that you have asked.
|
|
|
|
|
thank u....
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
Mail To : foreverkans@gmail.com
|
|
|
|
|
hi...
i got answer.. but i hve morethen 20 textbox in form..
so what ever its i press f1 key its open new form...
In ur keypress event perform well. any alternative solution
for form event not a textbox key press event...
thanks
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
Mail To : foreverkans@gmail.com
|
|
|
|
|
Hi All,
Hope someone can help on this one.
We have a small app that was developed in VS2008 using VB. App links to a small database using Access 2007 and for clients who do not have Access installed then we provide the Access Database Engine redistributable for them to install and use. App works fine and does all we want with one exception. In some, not all, cases the dates that are saved are stored in mm/dd/yy format (American) rather than the normal (Australian) dd/mm/yy for us. We originally thought this was due to local regional settings on the machine but it is not as we have the situation regardless of what region is selected. Then thought that the Access Database Engine was not region aware but we have clients using the app plus the database engine and the dates are saved in both formats dependent on the client but we can find no link - I know there must be one somewhere!
The field definitions in the database for the relevant fields are set to short date format. We have tried to force the code to save dates in a predetermined format (dd/mm/yy) but this does not work either. Any date after the 12th of the month is saved correctly so I know it must be down to region awareness or similar. Has anyone any suggestions as to what causes the problem and what can be done to resolve it.
Thanks in advance
Rick
|
|
|
|
|
This is a common issue with Access - has been for years...
Trick is to use this date format when writing your SQL to store the dates:
yyyy-mm-dd
Access doesn't actually store dates in a specified "date" format - it simply converts them and displays them however your code requests it to when you get it back out again.
Sadly, there's no easy way to fix your date issue (in your data) - as you have correctly identified that some dates are correct, and some aren't.
Hope this helps.
|
|
|
|
|
Damian,
Thanks for the reply, I have been aware of the issue with Access and dates for some time as well and this is why we force the code to hold dates in the ISO format (yyyy/MM/dd). We do not have date formats mixed up within the same database. It is from database to database or user to user if you like so do not have to fix data as such. I am trying to identify why we have a problem only on some machines but think we may have to ignore trying to identify the problem and merely work around it by controlling how dates are displayed in the app - but thanks for the answer.
Rick
|
|
|
|
|
how do i count the rows from table in vb.net?
tell me the code..
|
|
|
|
|
Hi, try this
if you have datatable with data from your database
if datatable.rows.count > 0 then
dim couns as integert = datatable.rows.count
endif
or
in your query: select count(*) from your tablename.
Hope this one can help.
Thanks
Hi, Please select Good Question if my answer are fit to your Question.
|
|
|
|
|
I just wonder if there is any universal way to make a child form accepting values from parent form and parent form accepting values from child form. I am using visual studio 2008.
|
|
|
|
|
Use delegates to send a message from child to parent, just access methods and properties of the child from the parent.
|
|
|
|
|
thanks for your answer.
Could you please give me an example?
|
|
|
|
|
Google broken where you live ? There's an article on CP on communication between forms, I suggest you look that up, it will go into more detail than I will go into for a forum reply.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
I need some code that will search UNC paths and return a confirmation message if a specified file is found, kinda like this
if \\machinename\path\file.ext found then popup "here it is"
Is this possible?
the simpler the code is, the better
|
|
|
|
|
|
|
I can only suggest that you read up on the .NET DragDrop process. If you like MSDN documentation, start here[^].
BTW if you are going to post code samples, please use the <pre></pre> tags and paste your code between them. This preserves a lot of the formatting and makes your code a lot easier to read.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
i have an authorised SSL certificate in the web server and when client invokes the html which is present inthe server...IE should display certificate like..
Security Alert box with yes ,no and view certificate buttons.....
and what are tags i need to add in html so that client client views it when trying to access the html.....
|
|
|
|
|
And this has what to do with VB.NET??
You still haven't picked up that book, haven't you??
|
|
|
|
|
Hi all,
I have an input file that has a field named "NAME".
I have to split this Name field into PARENT and CHILD fields.
The alignement of the CHILD field is not proper, kindly bare with it...
Code I have Done:
Iam not sure whether to use IF ELSE or While Loop
I think i have to read the next line with in the If statement that i have used...
But Im not sure..;
Thanks in Advance.....
modified 28-Nov-12 8:30am.
|
|
|
|
|
I think it's a bit more complicated than deciding whether or not to use IF..ELSE or LOOP. You have more than two generations in the data i.e. ASMs contain ASMs that contain PRTs (parent-child-grandchild).
Here's some code that I've been playing with.
There is at least one bug in it but the general idea is sound (I think ).
Imports System.IO
Module Module1
Sub Main()
Call Parent_Child1("C:\PlayPen\Names.txt", "C:\PlayPen\Names_OUT.txt")
End Sub
Private Sub Parent_Child1(ByVal iFile As String, ByVal oFile As String)
Dim previousSpaces As Integer
Dim currentSpaces As Integer
Dim pF(10) As Integer
Dim parentStack(5) As String
Dim generation As Integer = 0
Dim name As String
Dim inputLine As String
Using sw As StreamWriter = New StreamWriter(oFile)
Using sa As StreamReader = New StreamReader(iFile)
inputLine = sa.ReadLine()
Call FillPF(pF, inputLine)
Call WriteHeader(sa, sw, inputLine, pF)
'Assume first data record is a parent
inputLine = sa.ReadLine()
name = inputLine.Substring(0, pF(1))
previousSpaces = NbOfCar(name, " ")
parentStack(generation) = name
'generation += 1
While sa.Peek() >= 0
inputLine = sa.ReadLine()
name = inputLine.Substring(0, pF(1))
currentSpaces = NbOfCar(name, " ")
If currentSpaces = previousSpaces Then
sw.WriteLine(parentStack(generation - 1) & name)
Else
If currentSpaces > previousSpaces Then
sw.WriteLine(parentStack(generation) & name)
previousSpaces = currentSpaces
generation += 1
parentStack(generation) = name
Else
' currentSpaces < previousSpaces
generation -= 1
previousSpaces = currentSpaces
sw.WriteLine(parentStack(generation) & name)
End If
End If
End While
End Using
End Using
End Sub
Private Function NbOfCar(ByVal s As String, ByVal c As String) As Integer
Dim i As Integer = 0
While (i < s.Length) And (s.Substring(i, 1) = c)
i += 1
End While
NbOfCar = i
End Function
Private Sub FillPF(ByVal p() As Integer, ByVal t As String)
p(0) = t.IndexOf("Nom du Modele")
p(1) = t.IndexOf("AEC_STANDARD_DESCRIPTION_FRENCH")
p(2) = t.IndexOf("AEC_FREE_DESCRIPTION_FRENCH")
p(3) = t.IndexOf("AWW_STANDARD_DESCRIPTION")
p(4) = t.IndexOf("AEC_FREE_DESCRIPTION_ENGLISH")
p(5) = t.IndexOf("AEC_ECN")
p(6) = t.IndexOf("DNF")
p(7) = t.IndexOf("BALOON")
End Sub
Private Sub WriteHeader(ByVal sr As StreamReader, ByVal sw As StreamWriter, ByVal t As String, ByVal p() As Integer)
Dim s As String = ""
s = t.Substring(p(1), p(2) - p(1)) ' desF
s = s & t.Substring(p(2), p(3) - p(2)) ' desAF
s = s & t.Substring(p(3), p(4) - p(3)) ' desA
s = s & t.Substring(p(4), p(5) - p(4)) ' desAA
s = s & t.Substring(p(5), p(6) - p(5)) ' ecn
s = s & t.Substring(p(6), p(7) - p(6)) ' dnf
s = s & t.Substring(p(7), t.Length - p(7)) ' baloon
sw.WriteLine("PARENT" & Space(10) & "CHILD" & Space(10) & s)
sw.WriteLine(sr.ReadLine()) 'The line of underscores
End Sub
End Module
It fails on the last record in this test file (and there may be other bugs.)
Nom du Modele AEC_STANDARD_DESCRIPTION_FRENCH AEC_FREE_DESCRIPTION_FRENCH AWW_STANDARD_DESCRIPTION AEC_FREE_DESCRIPTION_ENGLISH AEC_ECN DNF BALOON
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
01530501.ASM
4281484M1.PRT
3009508X1.PRT
3009508X1.PRT
3009506X1.PRT
3009506X1.PRT
3583428M1.PRT
3583428M1.PRT
3583428M1.PRT
4282884M92.ASM
4282885M2.PRT
4281478M1.PRT
4281479M1.PRT
390734X1.PRT
390734X1.PRT
390734X1.PRT
3009495X1.PRT
3009495X1.PRT
3009495X1.PRT
3385604M2.PRT
3385604M2.PRT
391039X1.PRT
4287200M3.ASM
391176X1.PRT
4281283M93.ASM
4284820M94.ASM
4282976M2.ASM
4282971M2.ASM
4285693M1.PRT
4284511M1.PRT
4284511M1.PRT
4284511M1.PRT
4284511M1.PRT
4284511M1.PRT
4284511M1.PRT
4284511M1.PRT
4284511M1.PRT
4281283XXX.ASM
You'll notice that I've dropped all the fields you were not outputting but they should be ewasy to put back in.
Hope this helps
Regards
David R
|
|
|
|
|
Here's a version that fixes the bug in previous one.
Private Sub Parent_Child1(ByVal iFile As String, ByVal oFile As String)
Dim pF(10) As Integer
Dim parentStack(5) As String
Dim generation As Integer = 0
Dim name As String
Dim inputLine As String
Using sw As StreamWriter = New StreamWriter(oFile)
Using sa As StreamReader = New StreamReader(iFile)
inputLine = sa.ReadLine()
Call FillPF(pF, inputLine)
Call WriteHeader(sa, sw, inputLine, pF)
'Assume first data record is a parent
inputLine = sa.ReadLine()
name = inputLine.Substring(0, pF(1))
parentStack(generation) = name
'Write out first record here if need to
While sa.Peek() >= 0
inputLine = sa.ReadLine()
name = inputLine.Substring(0, pF(1))
generation = GetGeneration(name)
parentStack(generation) = name
If (generation > 0) Then
sw.WriteLine(parentStack(generation - 1) & name)
Else
'Do you need to do this for lines that have no parent?
sw.WriteLine(parentStack(generation))
End If
End While
End Using
End Using
End Sub
Private Function GetGeneration(ByVal s As String) As Integer
Dim g As Integer
g = NbOfCar(s, " ")
If (g > 1) Then
g = (g - 1) / 2
End If
GetGeneration = g
End Function
It assumes that the first child generation has 3 spaces; the second has 5 spaces,; the third has 7 spaces and so on. If that's not the case then GetGeneration() might have to be modified.
You'll notice it is a bit different from my original effort. That's because I put my thinking head on and realised that the number of spaces tells you the generation and the parent must be the previous generation!
Regards
David R
|
|
|
|
|
|
I thought this might be the case. As I said this means modifying GetGeneration().
Here's a version that should work.
Private Function GetGeneration(ByVal s As String) As Integer
Dim spaceCount As Integer
Static maxSpaces As Integer = -1
Static lastGen As Integer = -1
Static genDict As Dictionary(Of Integer, Integer) = New Dictionary(Of Integer, Integer)
spaceCount = NbOfCar(s, " ")
If (spaceCount > maxSpaces) Then
lastGen += 1
genDict.Add(spaceCount, lastGen)
maxSpaces = spaceCount
End If
GetGeneration = genDict(spaceCount)
End Function
You also need to modify the Parent_Child1 sub to add the line in bold as below.
'Assume first data record is a parent
inputLine = sa.ReadLine()
name = inputLine.Substring(0, pF(1))
generation = GetGeneration(name)
parentStack(generation) = name
'Write out first record here if need to
I've not fully tested this but it seems ok on a modified version of the test file I sent in previous post.
Regards
David R
|
|
|
|
|
The code reads the input file and writes to the output file.
But not for the entire file.
Giving error message after few lines written..;
I'm getting this error message "The key data were missing from the dictionary." in the line below:
GetGeneration = genDict(spaceCount)
|
|
|
|