|
If clicking the two buttons causes the same code to execute, why do you need two buttons?
-------------------------------------------
Damian - Man of changing signature.
|
|
|
|
|
No, further i want to do code to distinguish between two button , whether i have clicked button1 or button2 .Is it possible???????
|
|
|
|
|
|
I did not get the meaning of
DirectCast(sender, Button)
Private Sub LotsOfButtons( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click, Button2.Click, _
Button3.Click, Button4.Click, _
Button5.Click, Button6.Click, _
Button7.Click, Button8.Click, _
Button9.Click, Button10.Click
Dim clickedBtn As Button
If TypeOf sender Is Button Then
clickedBtn = DirectCast(sender, Button)
MsgBox(clickedBtn.Text)
End If
End Sub
Should i imports any framework class to use this function?
|
|
|
|
|
is DirectCast(sender, Button) some sort of CTYpe(sender,button) ?
If yes then DirectCast is any predefined function??????
|
|
|
|
|
|
Making the two function either it is user define e.g
private sub button1_click(byval sender as system.objects , byval e as system.eventargs)handles button1.click
and Change the Name Of Second Function and replace the Handeler name Button2
Please try it
|
|
|
|
|
by using the following code you can distinguish between the two buttons
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click, Button5.Click
Dim btn As Button = CType(sender, Button)
If btn.Text = "ASDFS" Then
Else
End If
End Sub
shally
|
|
|
|
|
I would like to be able to modify data a program uses for calculations and have it remain as default for the next time the program runs. I can't think of a way to do this with out using a seperate ini or cfg file. If someone could give me a clue I would appreciate it.
thanks
bill a.
|
|
|
|
|
You can use a config file, XML file, Registry, or Isolated Storage. You have to put it somewhere. it's up to you where that somewhere is and the format of the file you write.
|
|
|
|
|
|
I suspected that was the only way. I can remember vaguely using a "poke" command to push data back into a compiled executable from the executing program, but that was using assembly language on a very old machine. I was kind of hoping that VB had an easy way of defining a storage structure within the program that could be modified on the fly.
thanks
bill a.
|
|
|
|
|
I want to give my user the ability to copy a list of Orders (based on MR # and PreviousVisitDate) to a new VisitDate when they are creating one. So this is what I have to do..
1. Select all Orders with the specified MR and PreviousVisitDate
2. Copy all of the returned records (to a new temp table??)
3. Change the Date in the returned records to the New Date they entered.
So now I will have the original list and the new list that looks just like it but with a different Date.
I am sure this is simple for most of you but I am struggling with it. Can anyone show me an example of how this would be done or point me to one that I can read through? Thanks for any help you can give me with this.
|
|
|
|
|
How this is done depends on your existing implementation. How are the records being selected? In what control are they displayed? Is this control bound to a DataSet?
If the displaying control is bound to a dataset, then the items returned by its SelectedItems property should be DataRow objects. All you would have to do is change the date in each DataRow, then possibly write the in that DataSet back to the database.
If not bound, then you would have to get the record ID numbers from the SelectedItems of your control and make the changes to the database using Sql statements, or whatever else you're storing this data in.
I can't give you a more consise answer, because we know nothing of your existing implementation.
|
|
|
|
|
Hello Dave, thanks for your reply.
When the user goes to enter a new VisitDate (text box) I have a checkbox below it for Copy Orders from existing Visit Date, when they check it They see a combo box with a list of previous Dates for this MR #. Once they select a previous Date and hit OK I need to run this behind the scenes. I need to find all of the orders from the selected Previous VisitDate and copy all of them and then change the date on those new records to the NewVisitDate that they entered in the text box. I know that the New Date and the Previous date are both coming over fine right now. I just need to start putting the SQL into place now. And that is where I got stuck.
The form I am working with is connected to my Access 2003 database via a DataSet.
If you need more information then just let me know.
-- modified at 16:12 Wednesday 23rd May, 2007
|
|
|
|
|
OK. I still know nothing of your implementation in code, so I'll just describe the generic versions.
Retrieve the records for that MR and previous date putting them into a DataTable using a DataAdapter. Change the date field in each row in the table, then call Update on the DataAdpater to write the changes back to the database. Refresh your bound controls and you should be all set.
Or, write an SQL UPDATE statement that selects all of the records that make the MR/PreviousDate restrictions and changes only those records to the new date. This would use an OldDbCommand and its ExecuteNonQuery method to launch the command. Again, refresh the bound controls.
UPDATE mytable SET mydatefield = ?newdate WHERE mydatefield = ?somedate AND MKID = ?selectedMKID
|
|
|
|
|
Ok this is what I have so far I am trying to create a temp table and pull data into it....
Dim NewVisitDate As Date
Dim PriorVisitDate As Date
Dim SQL As String = String.Empty
Dim DT As New DataTable("TempVisitTable")
'set Variables
NewVisitDate = txtVisitDate.Text
PriorVisitDate = Me.cbobxPriorDates.Text.ToString
MR = frmQuestionnaire.txtMRNo.Text
'
SQL = "SELECT OrderMR, OrderDate, [Order] FROM (Orders) WHERE (OrderMR='" & MR & "') and (OrderDate= #" & PriorVisitDate & "#)"
Try
Connection.Open()
Dim Command As New OleDbCommand(SQL, Connection)
Command.ExecuteReader()
DT.Load(SQL)
Catch ex As Exception
End Try
When I do this I get a message on the DT.Load(SQL) that says...Unable to cast object of type 'System.String' to type 'System.Data.IDataReader'.
I am sure this is a syntax problem. Can someone tell me what I am doing wrong here?
|
|
|
|
|
CCG3 wrote: DT.Load(SQL)
The Load method is looking for a DataReader as a parameter and you gave it a string.
The ExecuteReader method returns a DataReader object, which you just ignored and dropped.
This code should read:
Connection.Open()
Dim Command As New OleDbCommand(SQL, Connection)
Dim dr As DataReader
dr = Command.ExecuteReader()
DT.Load(dr)
But, like I said before, another alternative would be to use an SQL UPDATE statement, where you would need to load this stuff into a temp table.
|
|
|
|
|
Hi,
Sorry to disturb you with such a beginners question but I am sort of stuck.
I have just started with VB and ran into the following.
I have an application which creates multiple logs. I have created a script which does a readall and inserts them into one big file. The problem is that it becomes on big file and the dates get mixed up and some log entries have the same time date. Is there some way to sort the dates.
Any hint or suggestion will be appreciated.
BR,
Jorgen
|
|
|
|
|
You'd have to parse this information and store and sort it yourself. There is no component that will do it for you. If all there was in the log was a date/time stamp and a line of text after it, I'd probably use a SortedList[^] implementation to hold all of the records from the logs, then output the SortedList, line-by-line to your compiled log file.
|
|
|
|
|
Thanks a lot. I will go with you suggestion.
BR,
Jorgen
|
|
|
|
|
Hi ppl,
PLEASE I AM SO DESPERATE!!!
This is ALL relates to the Speech recognition technology by MS and to the released SDK of "Sapi 5.1"..
a link to the SDK:
http://www.microsoft.com/downloads/details.aspx?FamilyId=5E86EC97-40A7-453F-B0EE-6583171B4530&displaylang=en[^]
i am trying to build a simple program of Sapi, which only uses "Command&Control" Grammer (from an xml) and not the dictation one..
i am using the sample from the SDK 5.1 of the Solitaire Game (Sol.xml-which i got in c:\), and i can't get it to work, i just can't understand why isn't it Recognizing... i am using VB 2005 express edition..
I DO NOT have errors in my code.. but the program is still not accepting
when i say "New game", i wish there was some Sapi SDK for vb.net cause it's not simple for a newbie like me to "translate" the code from vb6 (as in the sample) to vb.net from the 5.1 SDK..
FOR SHORT- IT'S NOT RECOGNIZING- AND IT'S DRIVING ME *CrAzY*
PLEASE take a look at the code and try to help me out...
I have a Recognition code by xml, label1, label2, and a textbox1..
(if you are trying that you should add a refernce of a com object by the name of "Microsoft Speech object library" version 5.0..
Public Class Form1
Public WithEvents RC As SpeechLib.SpSharedRecoContext
Public myGrammar, b As SpeechLib.ISpeechRecoGrammar
Private Sub Form1_Load()
RC = New SpeechLib.SpSharedRecoContext
myGrammar = RC.CreateGrammar
myGrammar.CmdLoadFromFile("c:\sol.xml", SpeechLib.SpeechLoadOption.SLODynamic)
myGrammar.CmdSetRuleIdState(0, SpeechLib.SpeechRuleState.SGDSActive)
End Sub
Private Sub RC_FalseRecognition(ByVal StreamNumber As Long, ByVal StreamPosition As Object, ByVal Result As SpeechLib.ISpeechRecoResult)
Label1.Capture = "(no recognition)"
End Sub
Private Sub RC_Recognition(ByVal StreamNumber As Long, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
Label1.Capture = Result.PhraseInfo.GetText '=NOTHING HAPPENS HERE
TextBox1.Text = Result.PhraseInfo.GetText '=NOTHING HAPPENS HERE
End Sub
Private Sub RC_StartStream(ByVal StreamNumber As Long, ByVal StreamPosition As Object)
Label2.Capture = Val(StreamNumber)
End Sub
End Class
I am sorry for the length of this msg.
I appriciate your help, no one answered and helped me anywhere else, but i have my hopes with you ppl here, cause it looks aweseme, I am new here, and it's my first question..
THANKS A MILLION!!!
Ray.
Only dead fish go with the flow..
|
|
|
|
|
None of this is going to work because the events are not wired up and you've got the method signatures using VB6 names for variables instead of VB.NET. For example, a Long type in VB6 is a 32-bit signed integer, while in VB.NET, Long is a 64-bit signed integer. The two are NOT interchangable.
Public Class Form1
Private WithEvents RC As New SpeechLib.SpSharedRecoContext
Private myGrammar As SpeechLib.ISpeechRecoGrammar
Private Sub Form1_Load()
myGrammar = RC.CreateGrammar()
AddHandler RC.FalseRecognition, AddressOf RC_FalseRecognition
AddHandler RC.Recognition, AddressOf RC_Recognition
AddHandler RC.StartStream, AddressOf RC_StartStream
myGrammar.CmdLoadFromFile("c:\sol.xml", SpeechLib.SpeechLoadOption.SLODynamic)
myGrammar.CmdSetRuleIdState(0, SpeechLib.SpeechRuleState.SGDSActive)
End Sub
Private Sub RC_FalseRecognition(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal Result As SpeechLib.ISpeechRecoResult)
Label1.Capture = "(no recognition)"
End Sub
Private Sub RC_Recognition(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)
Label1.Capture = Result.PhraseInfo.GetText()
TextBox1.Text = Result.PhraseInfo.GetText()
End Sub
Private Sub RC_StartStream(ByVal StreamNumber As Integer, ByVal StreamPosition As Object)
Label2.Capture = Val(StreamNumber)
End Sub
End Class
Warning! I haven't tested this code and don't have the time to. Use at your own risk!
|
|
|
|
|
THANK YOU FOR ENLIGHTING ME...
but the code still doesn't work, and i still can figure out where the problem is.. what am i doing wrong??????, i am just dieing so it would work for 2 months now..
but i have made a progress with your comment about the handlers, i could never get it right otherwise anyway..
Thanks again..
anybody else? please?
Ray.
|
|
|
|
|
sapi.dude wrote: but the code still doesn't work
Explain what "doesn't work" means? Are there any error messages? Compile or runtime errors?
|
|
|
|