|
I have a series of forms which have textboxes that require data to be entered over the page.
1/ How do I make it so that the cursor jumps to the next textbox (in the order I program) when the "enter" button is hit, regardless of whether or not any data has been entered?
2/ Can I set a key to reverse up in the same manner? eg. the left arrow key.
Sorry if this is a simple one, but I have been searching and not finding much helpful info.
Thanks F
|
|
|
|
|
Handle the KeyPress event of ALL the textboxs on your form. in that handler, look for the ENTER key being pressed and call the GetNextControl method of the control that fired the KeyPress event. That'll return the next control in the Tab Order. All you need to do then is call the Focus method of the returned control.
|
|
|
|
|
Many Thanks Dave for your help.
|
|
|
|
|
Hi, I have a problem when get the sum of value from Ms access. I have a table with column name LGVal (currency). This table cotain many record and I want to calculate the total of LGVal. The below is the code that I wrote:
Private Sub MonGrantItem()
' Clear the previous item.
lvwGrant.Items.Clear()
' Declare the new command to get grant from the database.
Dim cmdGetGrant As New OleDbCommand
With cmdGetGrant
.Connection = cnnDonorDb
.CommandType = CommandType.Text
.CommandText = "SELECT tblProgBudgetDetail.LGName, tblProgBudgetDetail.LGVal FROM tblProgBudgetDetail WHERE tblProgBudgetDetail.ProgBudIDDetail =" & CInt(strSubProgID) & " AND tblProgBudgetDetail.SourceType = False ORDER BY tblProgBudgetDetail.LGName" ' Source type = false mean Loan.
End With
' Open the connection.
Try
cmdGetGrant.Connection.Open()
Catch exFileNotFound As System.Data.OleDb.OleDbException
MessageBox.Show("The system has a problem to connect to your database system." & ControlChars.CrLf & "Please verify that your database is located in the following path: 'C:\DICDonorDb\DICDornorDb.mdb'", "Database file not found", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
Dim drdGetGrant As OleDbDataReader = cmdGetGrant.ExecuteReader
If Not drdGetGrant Is Nothing Then
Dim lstGrant As ListViewItem
While drdGetGrant.Read
lstGrant = New ListViewItem(drdGetGrant(0).ToString)
lstGrant.SubItems.Add(drdGetGrant(1).ToString)
lvwGrant.Items.Add(lstGrant)
End While
End If
' Close the connection.
cmdGetGrant.Connection.Close()
' Declare the new command to get grant from the database.
Dim cmdTotalGrant As New OleDbCommand
With cmdTotalGrant
.Connection = cnnDonorDb
.CommandType = CommandType.Text
.CommandText = "SELECT SUM(tblProgBudgetDetail.LGVal) FROM tblProgBudgetDetail WHERE tblProgBudgetDetail.ProgBudIDDetail =" & CInt(strSubProgID) & " AND tblProgBudgetDetail.SourceType = False" ' Source type = false mean Loan.
End With
' Open the connection.
Try
cmdTotalGrant.Connection.Open()
Catch exFileNotFound As System.Data.OleDb.OleDbException
MessageBox.Show("The system has a problem to connect to your database system." & ControlChars.CrLf & "Please verify that your database is located in the following path: 'C:\DICDonorDb\DICDornorDb.mdb'", "Database file not found", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End Try
Dim drdTotalGrant As OleDbDataReader = cmdTotalGrant.ExecuteReader
' **************************************************************
'
' CONTAIN ERROR IN THIS POINT.
'
' **************************************************************
Try
lblTotalGrant.Text = "Total Grant: $ " & drdTotalGrant(0).ToString
Catch exNoRow As System.InvalidOperationException
lblTotalGrant.Text = "Total Grant: $ 0.00"
Finally
' Close the connection.
cmdTotalGrant.Connection.Close()
End Try
' Enable or disable update and delete button for grant.
If lvwGrant.Items.Count > 0 Then
btnUpdateGrant.Enabled = True
btnDelGrant.Enabled = True
Else
btnUpdateGrant.Enabled = False
btnDelGrant.Enabled = False
End If
End Sub
The bold line is the line that has an error. The bold and italic line is the line that I suspect to cause an error. Please help me to solve the problem. Thank in advance.
|
|
|
|
|
Please tell me the errror you are getting.
Ahamed Azeem
software Programmer
|
|
|
|
|
Now I could solve it. I forget to add the code [DataReader].Read in my code editor. Thank you for your help
|
|
|
|
|
Can any one let me know how to sort the values returned by a object data source using IComparer based on last name , first name and followed by date of birth? Step by step procedure is highly appreciated. You can send the code to soori007@yahoo.com
|
|
|
|
|
smutukundu wrote: You can send the code to
Not a chance! If you want help, then the whole community must benefit. We are not here just for you. Other people may have a similar problem.
|
|
|
|
|
That's OK. i can understand. Thanks for ur reply. But can u post the solution on the blog. It will be so helpful. Thank u once again.
|
|
|
|
|
I created a context menu strip that opens up when you click on an icon in the taskbar, but it will not close when i click on the desktop or on another application. I tried a couple of things and i noticed that it probably has something to do with the focus, but i cant figure out how to do it.
Any help is appreciated
|
|
|
|
|
On a remoting project I use a Class Library that implements an Interface and Several Classes,
My client applications (windows services) use the Interface for remoting one or some of the classes from the Class Library as parameters sent to a Server Application (windows application).
Everything works fine as long as I don´t SIGN the assemblies, but the moment I SIGN the assemblies
all subs or functions that use the classes from the Class Library as parameters fail to be
'Transmitted' to the Server Application, however the same subs keep working if the parameter is a string, a hashtable or any other system type.
Note I said 'Transmitted' because I don´t know a better term to express the problem
I must say that No Exception is ever thrown, all assembiels reference the same Class Library
with same Keys, versions and Tokens
1.- Is a permission attribute missing?, which one at code level?
2.- I don't want to use
<Assembly: Security.AllowPartiallyTrustedCallers()>
as all code inside the assembly would be exposed to PartiallyTrusted Callers
3.- Must I use the GAC (MSDN says it is not necessary)
Example (All unnecessary code stripped)
<pre><Serializable()>Public Class ClsStatistics
Private _hits as Long = 0
Public Property Hits() As Long
Get
Return _hits
End Get
Set(ByVal value As Long)
_hits = value
End Set
End Property
End Class</pre>
Does anybody have the same problem or answer
Ramon Barreda
ramonb0@msn.com
|
|
|
|
|
I am having significant problems setting the ip address/subnet/default gateway from a vb.net windows application. The trouble I am having is that it appears there is no service key in the registry to point me to the tcpip key in the currentControlSet. The key below
SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkCards\1
appears in some of the articles I have found, but that does not seem to point to the correct service for active network cards. There is no ..\CurrentVersion\networkCards\ folder in:
SOFTWARE\Microsoft\Windows\CurrentVersion\NetworkCards\1 as I would suspect.
Any help is appreciated.
dave
dave
|
|
|
|
|
You have two problems. First, you're looking in the wrong place to set the IP. Second, you're trying to poke the IP into the Registry. Don't.
Use the appropriate tool. WMI and the Win32_NetworkAdapterConfiguration[^] class, specifically, the EnableStatic method.
|
|
|
|
|
Thanks for your response,Dave. I think I have this one almost worked out with the exception of the following.
strIPAddress = "192.168.1.141"
strsubnetMask(0) = "255.255.255.0"
strGateway(0) = "192.168.1.1"
strGatewayMetric(0) = 1
For Each objNetAdapter In colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strsubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewayMetric)
Next
The MSDN web site indicates passing the ipaddress variable into the Array(string) function prior to calling EnableStatic. There is no support for the array function in .net. Using conventional 1-demensional arrays throws a type mis-match exception. The exception is just a pretty unhelpful "type mismatch" message. Anyone see something i am missing?
dave
|
|
|
|
|
First, the IPAddress is not a string array, which is what EnableStatic expects.
Dim ipAddresses() As String = {"192.168.0.1"}
Next, you're setting the IP address of ALL the network adapters to the same address. You CANNOT do that!! You have to do it on the SINGLE adapter that is the network connection that you are changing, NOT ALL OF THEM!! There are more adapters in the system than appear in the Network Neighborhood properties box...
|
|
|
|
|
I am trying to make my connection string variable using application settings under Project properties. Here is my connection string when it is hard coded:
Dim myConnString As String = "Provider=Microsoft.Jet.OleDB.4.0;Data Source=" & Application.StartupPath & "\File.mdb"
When I have it hard coded it works fine. But when I try to make it variable I keep getting the error: Format of the initialization string does not conform to specification starting at index 33.
For the connection string value, I have the same code as posted above and I placed the following in the code: Dim myConnstring As String = My.Settings.ConnectionString
ConnectionString is the name of the value in application settings.
Can anyone help me with this connection string please. I know it may seem easy but I can't get it to work.
jds1207
|
|
|
|
|
Putting
"Provider=Microsoft.Jet.OleDB.4.0;Data Source=" & Application.StartupPath & "\File.mdb" in the settings won't work. You have to write some code to retrieve a complete string, like:
Provider=Microsoft.Jet.OleDB.4.0;Data Source={0}
from the config file, then replace the {0} with the value returned by Application.StartupPath .
Public Shared Function GetConnectionString() As String
Dim configString As String = My.Settings.ConnectionString
' Replace the {0} with the value from StartupPath.
' As a side, you can either pass in the filename of the database, or retrieve that
' from a setting in the config file also.
Return String.Format(configString, Path.Combine(Application.StartupPath, "File.mdb"))
End Function
|
|
|
|
|
Thanks, that worked great!
jds1207
|
|
|
|
|
Hi,
I have to wokr out in an application where user can write/open/save letters. Then I have to mail merge that letter with the data source I have. I use MS Access and Vb.NET 2005.
Also, I should have basic word features like in any mail - B, I, U, Align, etc.
I am wondering how can I do it - If i save the letter in a doc file, then how to perform the mail merge thing. Usualy mal merge in word has <<firstname>> ... such tags & data is set for those tags & process is done. How can and how sould I perform the activities.
Please help me out. I am in a hurry, looking from couple of days for this problem but couldn't find any substantial help line.
Any help is appreciated.
Thanks
Trupti
Thanks
Terry
|
|
|
|
|
Trupti Mehta wrote: I am wondering how can I do it - If i save the letter in a doc file, then how to perform the mail merge thing. Usualy mal merge in word has <<firstname>> ... such tags & data is set for those tags & process is done. How can and how sould I perform the activities.
If the user already has Word, why are you trying to re-invent it??
Or are you making your own document editor and trying to do MailMerge yourself??? If so, the merge part is easy. Your user is going to have to type fields into the document using some format you specify, like <<firstname>> , then you retrieve your results from the database and do a simple search and replace, matching the field names in the database results to the ones specified in the document.
|
|
|
|
|
Thanks Dave for the quick response.
I got to add this feature in an application. It is basically sending mails to customers of the DB. The user wants all basic features like B, I, U, fonts etc in the editor. Make a new file, Open an existing file, make changes in it, save the file, and set it to do the mail merge part via my application. The DB has customers details. To implement the text features, i got to ise RTF text box. That saves the file in rtf, txt or html. I will give only rtf format. Those features, file opening, saving are almost managed. I amaware of mail merge process procdure.
I am wondering, when user creates a new file or opens a file, and setss it for mail merge, how can I set the customers name, adress, etc in the rtf file, and make a seperate page for each customer with his address. And truly saying, I have no idea for the mail merge tags - <<firstname>> etc.
This is my main part of the problem. Please help me for it and guide accordingly. I wouldl ike to know if anywher I am choosing a wrong way out.
Thanks
Terry
|
|
|
|
|
This is too simple. Replacing a field in a string is as easy as finding the field tag and replacing it with the string retrieved from the database. I don't get where you're getting hung up on this.
|
|
|
|
|
I have a Rich text box, where user opens or creates a new letter. Which I got to do mail merge.
User wont enter tags or such thing. That part I wil only have to do. How do I insert such tags and make that template ready for mail merging?
I was wondering to just add the field values without tags. If user opens a file that has such tags, then, how do I manage it? As I will input field values.
In case, To insert tags for later use, Word uses << >> in some other char. that these chars.
How to fulfill the above points? This is what is bothering me. One more point is bothering me, Can I do Mail merge with rtf file. As using rich Text box, file will be saved s rft. If I am not wrong Rich text doesn't support .doc file. Can I perform Mail merge in RTF file using Wod with my application.
I would be glad if you can help me resolve my these queries and free me to continue with my work. Try to response soon.
Thanks
Thanks
Terry
|
|
|
|
|
Trupti Mehta wrote: How do I insert such tags and make that template ready for mail merging?
Uhhh, how about typing them into the document?? You pick the format for the tags! How about :firstname: , or <<lastname>> , or #address# , or ...
Trupti Mehta wrote: I was wondering to just add the field values without tags.
Then how is the code going to know where to put the merged data?
Trupti Mehta wrote: If user opens a file that has such tags, then, how do I manage it? As I will input field values.
Manage what? I thought the data was comming from a database?
Trupti Mehta wrote: In case, To insert tags for later use, Word uses << >> in some other char. that these chars.
Uhhh.... WHAT???
Trupti Mehta wrote: If I am not wrong Rich text doesn't support .doc file.
No, it doesn't. THe RichTextBox doesn't know anything about Word's file format, and hence doesn't support it.
Trupti Mehta wrote: Can I perform Mail merge in RTF file using Wod with my application.
Again, I ask you, since you already have Word, why are you re-inventing the wheel?? Why not just do this whole thing in Word and forget coding a solution to a problem that already has a solution??
|
|
|
|
|
Dave Kreskowiak wrote: Trupti Mehta wrote:
Can I perform Mail merge in RTF file using Wod with my application.
Again, I ask you, since you already have Word, why are you re-inventing the wheel?? Why not just do this whole thing in Word and forget coding a solution to a problem that already has a solution??
Dave, then you tell me, if a client wants such feature in his software, how do i implement it. I have the customers DB. Client wants B, I, U .. features, so Rich text box is required. Client want to write new/edit letter and Prepare mail merge the letter to selected customers and facility to print the leters.
Now what and how to do, can you please suggest me! I would be glad to know some solution that you have in your mind for this kind of application. I am using VB.NET 2005 and MS ACcess DB.
Thanks
Thanks
Terry
|
|
|
|
|