|
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?
|
|
|
|
|
What i meant when i said it's not working, i meant that it is not recognizing and outputting the result to the textbox1 or changing the text of label1 or anything, it supposed to have only this one command that i have in the XML file which is "New Game" and when i say it, it's supposed to recognize it, and output the result (text-New Game) to the textbox or label or anything, but it doesn't do it, it looks like it doesn't even go to the Recognition Sub, and i don't know why, i am a begginer, but all i want to know now is this, i want this simple code to work, and then it would give me a huge jump start for my project and my learning skills since then i could move on everything else.. which i don't belive i will have much prblems with..
I appriciate your help..
and i hope i am not to rude asking for it..
Thanks again..
Ray.
|
|
|
|
|
You might want to try adding these two lines to your code:
myGrammar.CmdLoadFromFile("c:\sol.xml", SpeechLib.SpeechLoadOption.SLODynamic)
myGrammar.CmdSetRuleIdState(0, SpeechLib.SpeechRuleState.SGDSActive)
myGrammar.DictationSetState SpeechLib.SpeechRuleState.SGDSInactive
myGrammar.CmdSetRuleIdState 0, SpeechLib.SpeechRuleState.SGDSInactive
Other than that, it's going to take some playing around to get this to work. I can't install the Speech SDK and mess around with it for you. But, go back to the examples you found and make sure your code is doing what the examples are for C&C. I found the examples you got this code from.
|
|
|
|
|
THANK YOU VERY MUCH!
I got a progress, it goes in to the Recognition subs and the loading grammer one too..
but it still doesn't work, i am working on it..
here is my code:
<br />
Public Class Form1<br />
<br />
Private WithEvents RC As New SpeechLib.SpSharedRecoContext<br />
Private myGrammar As SpeechLib.ISpeechRecoGrammar<br />
<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
myGrammar = RC.CreateGrammar()<br />
AddHandler RC.FalseRecognition, AddressOf RC_FalseRecognition<br />
AddHandler RC.Recognition, AddressOf RC_Recognition<br />
AddHandler RC.StartStream, AddressOf RC_StartStream<br />
myGrammar.CmdLoadFromFile("c:\sol.xml", SpeechLib.SpeechLoadOption.SLODynamic)<br />
myGrammar.CmdSetRuleIdState(0, SpeechLib.SpeechRuleState.SGDSActive)<br />
myGrammar.DictationSetState(SpeechLib.SpeechRuleState.SGDSInactive)<br />
myGrammar.CmdSetRuleIdState(0, SpeechLib.SpeechRuleState.SGDSInactive)<br />
<br />
End Sub<br />
<br />
Private Sub RC_FalseRecognition(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal Result As SpeechLib.ISpeechRecoResult)<br />
<br />
Label1.Capture = "(no recognition)"<br />
<br />
End Sub<br />
Private Sub RC_Recognition(ByVal StreamNumber As Integer, ByVal StreamPosition As Object, ByVal RecognitionType As SpeechLib.SpeechRecognitionType, ByVal Result As SpeechLib.ISpeechRecoResult)<br />
<br />
Label1.Capture = Result.PhraseInfo.GetText()<br />
TextBox1.Text = Result.PhraseInfo.GetText()<br />
<br />
End Sub<br />
Private Sub RC_StartStream(ByVal StreamNumber As Integer, ByVal StreamPosition As Object)<br />
<br />
Label2.Capture = Val(StreamNumber)<br />
<br />
End Sub<br />
End Class
I hope I will get it right now..i am still working on it,
and i am not intending to give up,
it's all i do all day in the last few days..
but i think that i am on the right track..
now you understand how much I Realy Realy appriciate this..
Thankssss!!!
Ray.
|
|
|
|
|
Thanks for the advice, i just GOT IT WORKING!!!
you guys are amazing..
NO WORDS.
(Besides THANKSSSS!!!!!!!!!!!!!!!)
Ray.
|
|
|
|
|
It is unlikely that anyone here will have the time or desire to grab your code and get it working for you, but I am willing to go so far as to do some research for you and give you some sample articles (below). Also please, Go to Barnes and Noble, spend a day buying coffee and reading vb.net books (try at least 1 c# book too, if only to be able to understand more sample code). I suspect your problem is not SAPI 5.1 and much more a lack of general vb.net programming knowledge. And whatever you do stick with it and don't quit. If you have more specific questions please ask.
Here is a vb article:
SAPI 5.1: Voice - Enabled Applications With VB[^]
Here are several c# ones
Writing SAPI 5.1 apps in CSharp[^]
Buliding Text to Speech Applications using SAPI 5.1 and C#[^]
Build a Speech Recognition Stock Quote App with .NET and SAPI 5.1
[^]
Because of the framework C# is closer in some ways to vb.net than VB6 is and there is more documentation available, so I would recommend ignoring the syntax and seeing if you can pluck out some useful code.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|
HI,
well, that is all i need from the programing world for now, since i don't realy have the time to study it for months, i do understand though, what is going on, besides a few little basic things which i don't understand in VB.net.. and i do study from the Msdn videos and any other source i can get my hands on, i appriciate your help, and the links, allthough i know them all pretty well, the first link is the one that started me going..
anyway, thank you for encourging me.. as i said on another msg, i just want this simple basic code to work, it would give me a jump start to everything else, and will improve my learning after i'll get it right..
and thanks for your help..
i realy realy appriciate it..
Ray.
|
|
|
|
|
No problem. I've had a light load the past week and I have appreciated the site in the past, so I have jumped in to answer questions. Its been fun, 5 minutes here and there throughout the day while I work.
The problem is that there is no telling what is wrong with your code or how long it would take to fix. Open ended questions like this are open ended time sinks. And despite the fact that I have a light load, I do have work to get done, and so do others who volenteer here.
My suggestion is set break points in your code, put watches on the objects and examine them. Step throught your code line by line and watch what it does. Read the examples and yes, study programming. If you can locate a specific problem and ask for clarification, it might be that someone will look at it, decide its not to much work to answer it for you and give you an answer.
topcoderjax - Remember, Google is your friend.
|
|
|
|
|