|
you should never use CStr/CDate. This is VB6 holdover stuff. Convert.ToXXX is your best bet, unless you don't know if the input is clean, then stuff like int.TryParse should be your first port of call.
In C# you can do this:
object o;
...
MyClass x = o as MyClass;
in this instance, x will be null if o is not an instance of myClass. You can also do this
if (o is MyClass)
{
// o is an instance of MyClass
}
I am sure VB can do the same, but I don't know the syntax.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I want to know how to design a 3-tier Architecture. Could you give me some information for example document or books to teach it. Thank you
|
|
|
|
|
What sort of app are you writing ( web/client ) ?
Basically - the presentation layer only deals with the UI and passing data to the business logic objects. These, in turn, use the data layer for any persistence of data.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
1. I am using VB.NET 2003 and when i am using multiply forms and i want show text in status bar but it's didn't show tell me how to send text in status bar when we are working with Mdi Forms?
2. how we get a blank data grid cell for input and how we put combobox or button in data grid.
please help me in it's
Thanz
Rehan
|
|
|
|
|
I believe you need to add a status panel to the status bar and set the text property of the status panel to allow you to view text in the status bar.
Sorry, but I can't help you with the data grid part of the question.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my homepage Oracle Studios[ ^]
|
|
|
|
|
I am trying to insert items into MySQL db using parameters but I keep getting this error message:
Failed to convert parameter value from a String to a DateTime.
Here is some sample code:
Dim myConnString AsString = "DRIVER={MySQL ODBC 3.51 Driver};" & _
"SERVER=192.168.1.27;" & _
"DATABASE=testship;" & _
"USER=;" & _
"PASSWORD=;" & _
"OPTION=3;"
Dim MyConnection AsNew Odbc.OdbcConnection(myConnString)
MyConnection.Open()
Dim MyCommand AsNew Odbc.OdbcCommand
MyCommand.Connection = MyConnection
MyCommand.CommandText = "INSERT INTO ls_orderitems (OrderDate, OrderCustomer, OrderAcctNum, OrderType, OrderSoNum, OrderItemPartNum, OrderItemPartDesc, OrderItemQty, OrderItemQtyRec, OrderItemQtyDtRec, OrderItemBO, OrderItemBODt,OrderItemCanceled, OrderItemCanceledDt, OrderItemNotes, OrderItemPONum, OrderItemRetailPrice, OrderItemSalePrice, Status, InsertDate) VALUES (@OrderDate, @OrderCustomer, @OrderAcctNum, @OrderType, @OrderSoNum, @OrderItemPartNum, @OrderItemPartDesc, @OrderItemQty, @OrderItemQtyRec, @OrderItemQtyDtRec, @OrderItemBO, @OrderItemBODt, @OrderItemCanceled, @OrderItemCanceledDt, @OrderItemNotes, @OrderItemPONum, @OrderItemRetailPrice, @OrderItemSalePrice, @Status, @InsertDate)"
MyCommand.Parameters.Add(New Odbc.OdbcParameter("@OrderDate", OdbcType.Date)).Value = OrderDate
MyCommand.Parameters.Add(New Odbc.OdbcParameter("@OrderCustomer", OdbcType.VarChar)).Value = OrderCustomer
MyCommand.Parameters.Add(New Odbc.OdbcParameter("@OrderAcctNum", OdbcType.VarChar)).Value = OrderAcctNum
MyCommand.Parameters.Add(New Odbc.OdbcParameter("@OrderType", OdbcType.VarChar)).Value = OrderType
MyCommand.Parameters.Add(New Odbc.OdbcParameter("@OrderSoNum", OdbcType.Int)).Value = OrderSoNum
|
|
|
|
|
Is OrderDate a string or a DateTime object? If it is a string then you need to convert it to a DateTime first.
|
|
|
|
|
I'm trying to send commands to a remote host using sockets. I'm able to send the first message or command, but after that any message or command I send to the remote host won't run. Here's what I wrote, may be someone can help me. The commented lines are just some different approaches I've tried. The lines Call wskServer.Get and AddText are apparently running just once.
#Region "Data Arrival"
Private Sub wskServer_DataArrival(ByVal sender As Object, ByVal e As Winsock2005DLL.WinsockDataArrivalEventArgs) Handles wskServer.DataArrival
serialPort.Encoding = Encoding.ASCII
Dim message As String
Dim temp As String
Dim state As String
message = ""
message = e.TotalBytes
temp = message
'Do While wskServer.State <> WinsockStates.Closed
Call wskServer.Get(message)
AddText("----" & message & "----" & vbCrLf, txtoutput)
If serialPort.IsOpen Then
serialPort.Close()
End If
serialPort.Open()
If temp = "4" Then
state = "On"
serialPort.Write("o")
line = serialPort.ReadByte
End If
If line = 65 Then
wskServer.Send("Luz verde en IOLine 5 esta prendida")
End If
If temp = "5" Then
state = "Off"
serialPort.Write("f")
line = serialPort.ReadByte
End If
If line = 66 Then
wskServer.Send("Luz verde en IOLine 5 esta apagada")
End If
' If message.Contains("%") Then
' serialPort.Write("f")
' End If
' line = serialPort.ReadByte
'Loop
'line = ""
serialPort.Close()
End Sub
Thanks for any help!!!!!
|
|
|
|
|
how can i see list of installed applications in a listview?
thanks.
(I cann't speake english well.)
|
|
|
|
|
I was working on the same project here recently.
There is a registry key that Windows stores all of the installed programs in, it's the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall key. All you have to do is read each SubKey there.
Hope this helps.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Sir/Madam,
I am creating the table at run time in MS-Access using vb.net.now the problem is , I wanted to know , Whether Can I programically ascertain , The table that i generated programically at run time , exist any more , or it is droped.
Please help.
Thanks and Regards
Pankaj
|
|
|
|
|
SoapWrapperHandler – Right Exception is passing as a parameter but return “Application Fault”
ExecuteHandlerChain – ExceptionPolicyEntry – “Application fault”
Handle – chainExecution – Input is passing as a “Message not found”, which is MQException and return “Application fault”
RethrowRecommended – IntentionalRethrow – ChainException – Message in Base 64.
Try // Here Input Exception is applicationfault
My code
Catch (ex as SoapException) .
throw EDF.Exceptions.ExceptionHelper.GetServiceException(ex);
End Try
// GetServiceException throw a different Exception ‘Exception has been thrown by the target of an invocation’
Exception raised by GetServiceException is of type TargetInvocationException, which is raised at the time of deserializing it.
Exception is raised at the time of deseriazing it, appException = TryCast(sf.Deserialize(strm), Exception)
Exception – TargetInvocationException
Message – Exception has been thrown by the target of an invocation.
InnerException – Object must implement Iconvertible
Source - mscorlib
While Original SoapException is “App. Fault” and its Innerexception is null.
|
|
|
|
|
This is just a series of somewhat disjointed statements. Is there something you wanted to ask?
I'm going to guess that the question might be: Why do I get the TargetInvocationException when I expect a SoapException?
The reason is that the fault is not in the SOAP part of the request. You mention that it is raised during deserialisation which indicates that the framework is having difficulty reconstructing your object. Specifically the deserialisation process is using reflection and the target (object) that reflection is using does not support what ever it is trying to invoke.
You may find it easier to create some unit tests around the serialisation/deserialisation process to determine where the problem lies rather than attempt to debug it with the overhead of SOAP interaction.
|
|
|
|
|
Hi there,
I have done a search for generating random numbers and have come up empty, as anything i have read does not make any sense to me.
Could someone please show me how i could do this.
What i would like to do is get a random number between to numbers, sound simple does it not.
|
|
|
|
|
It sure is simple. Are you using VB.NET ? If so, Random.Next is all you need.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Christian Graus wrote: It sure is simple. Are you using VB.NET ?
In this forum, you have to ask the above question quite often. It's boring..., VB6 and VB.NET are completely different topics.
Sorry, I want only to share a bit my frustration...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
MSDN is your best friend, for instance:
To produce random integers in a given range, use the following formula.
(Visual Basic)
randomvalue = CInt(Int((upperbound - lowerbound + 1) * Rnd() + lowerbound))
if you use .NET then you have to deal with Random class, again, MSDN will help, see here.
To obtain more detailed help, please, clearify your needs (e.g. Do you need integers or double numbers?) and tell me the programming language you intend to use.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thank you for your replys.
This is what i had and was not doing the job(kept on going out of bounds,which cause an error)
RandomValue = CInt(Int(upper) * Rnd() + lower)
your code fixed that problem in the test app. Will try in in my app.Just to make sure it works;)
oh, BTW i forgot to say which language i was using thought that you would have been a mind reader
I am using VB2005.
I am back, thought i used the same post....
I changed your line to the following :-
RandomValue = CInt(Int(upper - lower + 0) * Rnd() + lower)
works perfectly now.
Thank again for all your replys.
-- modified at 5:36 Friday 5th January, 2007
|
|
|
|
|
If you are using VB2005, then dont use the solution provided, as it is for VB6. Use VB.NET, which means Random.Next
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Wel l my system will not recognize the command .next with the Random command????
|
|
|
|
|
Public Class Form1
.
.
Private RNG As New Random()
.
.
.
Dim newInteger As Integer = RNG.Next(0, 1000)
.
.
.
Seriously, pick up a beginners book on VB.NET. This is an easy one that gave you a ton of trouble. Learn the basics before you frustrate yourself out of doing this.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Everything is EASY, once you have done it.... My Friend;P
and i have a book but it does not say anything about random numbers.....
Mastering VB2005 EE
As allways, Thank You for your input.
|
|
|
|
|
WestSideRailways wrote: Everything is EASY, once you have done it....
That's true. But, if you couldn't follow the MSDN help, then the problem is not a book on VB, it's knowing enough VB to be able to navigate sources of new information. I second what Dave said, you need to learn some basics, so that you're able to use information sources. I expected you to realise I was telling you that there's a Next method on the random class, and to be able to work out that you need to create an instance of the Random class.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
The idea of being a good gru , is knowing that not every body it at the same level as yourself.
and sometimes you might have to come down off the high horse and help the people , by explaining what you have said in more detail. Don't expect some people to know what you are talking about , just because you do. I know it a bad habbit that we all do to other people at work, myself included.
Hopefully you don't take this the wrong way.Was not meant to be taken the wrong way, I am just giving my opion on the matter. Again hopefully when i ask another question you might remember this and answer in a more explain way.
|
|
|
|
|
Well, had Dave not stepped in, I would have answered in more detail. The truth is, I give a first answer that means that anyone with access to google has all they need. Anyone who proves incapable of using google, or perhaps, understanding what MSDN says, I will give deeper help. But, spoon feeding people on every simple question, that can be answered by google in seconds, is not helping them. I'm trying to teach people how to search for information themselves, when the question is trivial.
And that's what someone who wants to help *should* be doing. No matter what your opinion, if you ask more, I will answer again. I don't keep track of what people say in the past, or keep a list of people to help, or not help.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|