|
Answered in this forum, in this[^] thread, just a few hours ago.
..and yes, I have verified whether the query works in Access
|
|
|
|
|
Hi Experts ,
I want the code or solution to suppress the strings(-) in crystal report.
There is functionality to suppress zero.
Thanks,
|
|
|
|
|
You can suppress a text field by checking the suppress box in the format editor of a textbox.
Tosch
|
|
|
|
|
I am new to VB 2008, and I am learning this new language VB. The project I started to write a small program Calculator that will do just like a real calculator on (Windows XP).
I ran in some problems when I am trying to write routine to accept "/" divide, "+" plus, and "-" minus from right side of the keyboard. with press NUMLOCK ON. When I press NUMLOCK ON, the program should accept the "/", "*", "-", "+" and perform arithmetic.
My program calculator now can accept "/", "*", "-" when I used the mouse to press buttons on the calculator's interface.
Can someone tell me what the code will be? I am stuck...and I need help..
how to write the routine that will accept the operand to perform the basic arithmetic
thanks for everyone can help!!
Andy
|
|
|
|
|
Handle the form's KeyPress[^] event. KeyEventArgs.KeyCode gives you the current key which is pressed.
|
|
|
|
|
From the KeyDown Event, you can check
if e.KeyCode =Keys.NumLock or e.keycode=Keys.NumPad0 or...whatever else as per the need.
|
|
|
|
|
I am using four timers and I think I need to use each one on a different thread.
I am somewhat new to VB. I have learned a lot in the last 10 months.
I just need someone to show me how to use threads w/timers. PLZ post some small
coding on how todo this.
Thanks in advance for everybodies help.
rspercy
If "You wash your feet and find a pair of socks " Then
"You ARE a Redneck"
End If
|
|
|
|
|
There are two types of timers available in .NET framework
1 - System.Threading.Timer[^]
2 - System.Windows.Forms.Timer[^]
The first timer runs a methods on a thread pool thread and the second one runs the method on the same thread. Second one is used with windows forms.
rspercy60 wrote: I am using four timers and I think I need to use each one on a different thread.
What type of timer are you using? You need to tell use, why you think each one should be executed on a different thread?
rspercy60 wrote: I just need someone to show me how to use threads w/timers. PLZ post some small
Looks at the MSDN documentation which I linked to see how timer is used. For threading, this[^] would be the excellent material available on-line.
|
|
|
|
|
I am using System.Windows.Forms.Timers. I have three controls, each control has to be activated
at the same time. Here is one timers code.
Private Sub TMPTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TMPTimer.Tick
If oldTemp < newTemp Then
oldTemp += 1
DirectCast((Me.BaseUI1.Frame(0)), CircularFrame).ScaleCollection(0).Pointer(0).Value = oldTemp
If oldTemp = newTemp Then
oldTemp = newTemp
DirectCast(Me.BaseUI1.Frame(0).FrameCollection(0), NumericalFrame).Indicator.DisplayValue = oldTemp.ToString() & "°"
TMPTimer.Enabled = False
End If
End If
If oldTemp > newTemp Then
oldTemp -= 1
DirectCast((Me.BaseUI1.Frame(0)), CircularFrame).ScaleCollection(0).Pointer(0).Value = oldTemp
If oldTemp = newTemp Then
oldTemp = newTemp
DirectCast(Me.BaseUI1.Frame(0).FrameCollection(0), NumericalFrame).Indicator.DisplayValue = oldTemp.ToString() & "°"
TMPTimer.Enabled = False
End If
End If
End Sub
This code is for a temperature guage, I have two other guages for wind direction and wind speed and all have to be activated at the same time. This is why I think I need threeds
rspercy
If "You wash your feet and find a pair of socks " Then
"You ARE a Redneck"
End If
|
|
|
|
|
I take it you need them all activated because you want the three incoming values to be taken at exact the same time?
If you make all four measurements in a single timer's tick event, they will be received within less than a millisecond of each other (depending on your computer ofcourse).
If you create four threads, they will each be activated from the main thread, within less than a millisecond from each other (depending on your computer ofcourse).
See where I am going with this?
My advice is free, and you may get what you paid for.
|
|
|
|
|
THNX a lot. Worked great. I added all into 1 timer, fantastic.
rspercy
If "You wash your feet and find a pair of socks " Then
"You ARE a Redneck"
End If
|
|
|
|
|
You're welcome.
By the way, the code you posted contains some flaws that will cause part of the code to never execute:
Private Sub TMPTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TMPTimer.Tick
If oldTemp < newTemp Then
oldTemp += 1
DirectCast((Me.BaseUI1.Frame(0)), CircularFrame).ScaleCollection(0).Pointer(0).Value = oldTemp
'The following code will never be executed
'because you already established that oldTemp is smaller than newTemp:
If oldTemp = newTemp Then
oldTemp = newTemp
DirectCast(Me.BaseUI1.Frame(0).FrameCollection(0), NumericalFrame).Indicator.DisplayValue = oldTemp.ToString() & "°"
TMPTimer.Enabled = False
End If
End If
If oldTemp > newTemp Then
oldTemp -= 1
DirectCast((Me.BaseUI1.Frame(0)), CircularFrame).ScaleCollection(0).Pointer(0).Value = oldTemp
'The following code will never be executed
'because you already established that oldTemp is larger than newTemp:
If oldTemp = newTemp Then
oldTemp = newTemp
DirectCast(Me.BaseUI1.Frame(0).FrameCollection(0), NumericalFrame).Indicator.DisplayValue = oldTemp.ToString() & "°"
TMPTimer.Enabled = False
End If
End If
End Sub
Move the bit that is the same in both:
Private Sub TMPTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TMPTimer.Tick
'Is it smaller?
If oldTemp < newTemp Then
oldTemp += 1
DirectCast((Me.BaseUI1.Frame(0)), CircularFrame).ScaleCollection(0).Pointer(0).Value = oldTemp
End If
'Is it larger?
If oldTemp > newTemp Then
oldTemp -= 1
DirectCast((Me.BaseUI1.Frame(0)), CircularFrame).ScaleCollection(0).Pointer(0).Value = oldTemp
End If
'Is it the same?
If oldTemp = newTemp Then
oldTemp = newTemp
DirectCast(Me.BaseUI1.Frame(0).FrameCollection(0), NumericalFrame).Indicator.DisplayValue = oldTemp.ToString() & "°"
TMPTimer.Enabled = False
End If
End Sub
My advice is free, and you may get what you paid for.
|
|
|
|
|
When my program first boots up, oldTemp = 0, newTemp = 84, newTemp is the current temperature
in my home town. The guage starts moving from 0 to 84. Now oldtemp = newTemp and the DirectCast statement gets executed. Now I change my zipcode to somewhere in Alaska, newTemp = 54, seeing oldTemp = 84, the guage starts moving backwards till it gets to 54 and and the DirectCast statement gets executed.
My code works just as it is suppose to. So far I have not had any exceptions popup on me and I have checked it with multiple zipcodes. The temperature, wind direction and wind speed guages all move
to thier correct temp, wind direction, and wind speed integers that are retrieved from yahoo.
rspercy
If "You wash your feet and find a pair of socks " Then
"You ARE a Redneck"
End If
|
|
|
|
|
You know what, I read your code wrong. Sorry about that. You are right, your code will work nicely.
My advice is free, and you may get what you paid for.
|
|
|
|
|
Dear friends
I need help, I'm developing a VB.net -SQL server 2000 application VB.net 2008 but i cannot connect Excel by the code:
Dim xlapp As Microsoft.Office.Tools.
or
Dim xlapp As Microsoft.Office.Interop.
'ExcelApplication doesn' appear by autocomplete
knowing that i added the Microsoft excel object library 11 and downloaded the PIA application
I have:
Microsoft Visual Studio Team System 2008
.Net Framework 3.5
Is my application incomplete
if i should use OLE DB please guide me how to Import and Export to an existant excel file
ezzat oraby
|
|
|
|
|
|
Hi Experts,
I want the code to fetch the last record of customer . I had written the code but it gives error when there is no record found in the table for the requested customer . Please help.
Thanking you,
My Code is ....
rss.Open("select max(orderno) As ono from measurementpant where custno='" & txtcustno.Text & "' AND length<>0 ")
no = Convert.ToInt32(rss.Fields("ono").Value) // here gives error
rss.Close()
rssearch.Open("select * from measurementpant where custno='" & txtcustno.Text & "' AND orderno='" & no & "' ", con, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockPessimistic)
|
|
|
|
|
Two possible options are:
1. check that the record count is greater than 0.
2. use Integer.TryParse() to do the conversion.
1 will tell you that there are no records for customer.
2 will tell you that it could not convert to integer - there may be a record but the field does not contain something that can be converted.
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
hi friend try this code:
Public Function GetMaxVal(ByVal TableN As String, ByVal FieldN As String)
If ConSql.State = ConnectionState.Closed Then ConSql.Open()
Dim CmdSqlGetMax As New SqlCommand("Select Max(" & FieldN &") _
As MaxVal From " & TableN, ConSql)
If Not DBNull.Value.Equals(CmdSqlGetMax.ExecuteScalar) Then
GetMaxVal = CmdSqlGetMax.ExecuteScalar
Else
GetMaxVal = 0
End If
End Function
I used the If statement to escape from the DBNull Hell, If cannot do you may use try .. Catch .. End Try to do
Good Luck
ezzat oraby
|
|
|
|
|
Hi,
Thanks but i want the code for Ms-access database
|
|
|
|
|
Third option, add an ISNULL function to your query;
SELECT ISNULL(MAX(orderno), 0) AS ono
FROM measurementpant
|
|
|
|
|
Sorry bro
SELECT ISNULL(MAX(orderno), 0) AS ono
FROM measurementpant
I suggest it may be
<pre>SELECT NOT ISNULL(MAX(orderno), 0) AS ono </pre>
<pre> FROM measurementpant</pre>
Tell me if wrong
ezzat oraby
|
|
|
|
|
I just ran them on SQL Server, with these results;
SELECT ISNULL(MAX(orderno), 0) AS ono
FROM measurementpant
-- Result for an empty table: '0'
SELECT ISNULL(MAX(orderno), 0) AS ono
FROM measurementpant
-- Result for a table with two tuples: '2'
SELECT NOT ISNULL(MAX(orderno), 0) AS ono
FROM measurementpant
-- Result: Incorrect syntax near the keyword 'NOT'.
Zizo_nis wrote: Tell me if wrong
Your SQL did not compute.
"Some mainframe users still wonder if SQL Server is reliable enough for them. We're a nuclear power plant—how much more reliable do they need it to be?"
-- Janice Hoerber[ ^]
|
|
|
|
|
Hi,
Thanks, But it gives syntax error
|
|
|
|
|
AjitMourya wrote: But it gives syntax error
My apologies, didn't try it on MSAccess. Here is the Access version;
SELECT IIf(IsNull(Max([orderno])), 0, Max([orderno])) AS ono
FROM measurementpant;
|
|
|
|