.net: CInt Returning -1 On A (seemingly Valid) String?
Apr 24, 2009
I have a strange problem where CInt (as well as Convert.ToInt32 or even Val) return -1 for a string "500". Using Gurock's SmartInspect for logging, I've checked all values at runtime (SiAuto... logs something, I'm posting the log below the code).
I am developing Windows Forms Application SRacq10 in VS2010 in VB.Net. It provides a WCF duplex service and obtains real time financial market data using COM object TWS (Trader Work Station) provided by Interactive Brokers, Inc. SRacq10 works well most of the time. Occasionally, it crashes; I have not been able to observe a pattern of circumstances when it crashes. When I try to add debug to a text file, I can never make it crash; that's not an acceptable solution in the long run. Here is the fault information when running the debug version outside of VS2010:
Event Viewer: Faulting application name: SRacq10.exe, version: 1.0.0.0, time stamp: 0x4de7a42c Faulting module name: MSVCR80.dll, version: 8.0.50727.4940, time stamp: 0x4ca2b271
how to do a seemingly simple object-oriented problem in VB.NET 2010. Basically, I want to be able to write code such that I could do the following:
Dim myObject as Object myObject.Group1.Command1() myObject.Group2.Command2()
[code]....
Very similar to how VBA handles objects, such as in Excel, I can use
Dim myBook as Workbook Set myBook = ActiveWorkbook myBook.Sheets(1).Range("A1").Value()
to get the value of the cell "A1" on the first sheet. This structure has been eluding me for some time now, and it would be great if anyone could suggest how to do it. I'm currently using a class and declaring all methods as Shared Friend inside subclasses, which throws warnings when I use it as I want to in other code.
i need some help on explaining to me whats going on in the code below. Basically, the code below is used to convert a bitmap image to grayscale level (black and white).
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim pic As Bitmap pic = picVisible.Image Dim X As Integer
Many times i was not getting correct output,then i put .tostring() at the end then it gave good output.so basically why do v need this?also Convert.ToInt32(cmd.ExecuteScalar()) why convert to int32?
Dim L16, L23, L45, t As Double Dim LBase, LAdjacent, LOpposite As Double L16 = 20
[Code].....
Both equations should be equivalent: I've simply replaced L16 with LBase, L23 with LAdjacent and L45 with LOpposite. Yet the first equation outputs 3586 while the second outputs 3587.
I'm quite a newbie in VB.NET (and VB on the whole). So my question could sound rather odd, but still. I've stumbled upon an issue with the CInt and converting a double to an integer.
The issue is the following: CInt(10.5) would be 10
CInt(10.51) would be 11, but I expected 10... (Got used to C# style conversion: (int)10.51 would be 10)
As pointed out here Integer.Parse VS. CInt the result is just rounded in some fashion. Nowever, all I need is to get only integer part and throw away the fractional one. How can I achieve such type of conversion in VB.NET? After a short research I assume that I can use Fix() funciton to do the trick, but is it the best choice ever?
I have built a DataTable from my database. Then I am looping through the rows and trying to access a string, however the value is being returned as each character in the string.
For Each theseRows In DisplayForm.MainTab.Rows If theseRows.Item("Last_Name") = userLast And theseRows.Item("First_Name") = userFirst Then
[Code]....
The Trap_Code values are two or three letter strings, the returned value is each letter once at a time. The loop seems to cycle through the individual characters of the string as an array rather than display the entire value, which is what I was hoping for.
G:DevelopmentDOT NET DevColony_4ImagesBattenhallAve_Plan.bmpand i want to find and return the value after the last '' for example in the string above i would want to return:BattenhallAve_Plan.bmp
I have the following value 48.81, it comes as a string from the database, I need to convert it to decimal, I'm using:
Dim Seconds As Decimal = Convert.ToDecimal((Coordinate.Substring(4, 5)), CultureInfo.InvariantCulture)
I'm receiving 4881D and I need 48,81
I thought CultureInfo.InvariantCulture was going to help me with that
EDIT:The coordinate value is 675900.244.I'm "spliting" it like this:
Dim Degress As Integer = Coordinate.Substring(0, 2), Dim Minutes As Integer = Coordinate.Substring(2, 2), Dim Seconds As Decimal = Convert.ToDecimal((Coordinate.Substring(4, 5)), CultureInfo.InvariantCulture),
[code]....
This is the value of the coordinate in the database?
I am using Virtual Basic with ASP.NET in Visual Studio 2008. I am using Webmethod to communicate from/to the server with the client. Data can be queried and returned in small amount, but when I try get a relatively large amount of data, it's returning me a Server 500 error. My data is 226561 character long, so it's not that large, but it's relatively larger than my other working testing set, which are about 10k character long.
JavaScript: PageMethods.my_func("context", success); function success(result, userContext, methodName) {
I am using Virtual Basic with ASP.NET in Visual Studio 2008. I am using Webmethod to communicate from/to the server with the client. Data can be queried and returned in small amount, but when I try get a relatively large amount of data, it's returning me a Server 500 error. My data is 226561 character long, so it's not that large, but it's relatively larger than my other working testing set, which are about 10k character long.
JavaScript: PageMethods.my_func("context", success); function success(result, userContext, methodName) {
[code]....
Is there anything I can change to increase WebMethod returned string length limit? Is there even a length limit or is it some other problem I could not see?
I have created a function which essentially enables me to output anything I need from my database in a similar method to Facebook's FQL querying method as a JSON text result. I can also use the same function to get the output as a Dictionary, or List of(Dictionary) to use with VB functions for other purposes.
This morning I was trying to work out how to update a User Control from a button on a page using jQuery.Refresh User Control with jQuery.From the info gleaned from this article: http [url]...I now have a method of loading a User Control as a page with jQuery using the converted .VB example from the codeproject.com article.However... this won't render into the browser, Firebug is giving the error "element must be contained within a form runat=server tag" So I posted this question:
re: better way to manage a dynamic select list using jQuery and User Control.Since posting that though,I have thought about it further, and believe it is the fact that the jQuery Handler class created by the codeproject code is send the browser a complete page.Given that I sadly don't really understand what that codeproject code actually does I am having trouble working out how to alter it.What I need it to do is not return a Page at all, but I guess, an HTML string, which can then be pasted directly as HTML into the div as required.how to alter that code to return an HTML string?
I'm trying to create a ntier desktop application using vb.net 2008.[code]...
By the way what i want to achieve is how to get the data as a List(Of String),because if i put the getMenu function into the presentation layer directly,it gives me the data as i expected..Also if i return as a string instead of List(Of String),it gives me the single data.
I make a query in coding. But I got conversion error.My query is below
Dim strSelect As String = "" strSelect = "SELECT " & _ "Description As [Desc], " & _
[code].....
Exception error is like
Conversion from string "iif(CurCons = 0, " to type 'Double' is not valid
Actually, in my report, i wanna show if it's zero then '-'. If i set it in this string.I got another error like below The provider could not determine the Decimal value. For example, the row was just created, the default for the Decimal column was not available, and the consumer had not yet set a new Decimal value.
From da.Fill Dim cmd As New OleDbCommand(strDynamic, m_DBConn) Dim da As New OleDbDataAdapter(cmd) da.Fill(ds, "tblCur")
I have an ASP.NET web application (VB.NET) using an Oracle database. On an insert, I need to get the identity of the inserted row back. I am trying to use RETURNING, but I keep getting a value of 1 returned.
Dim strInsert As String = "INSERT INTO L.TRANSACTIONS (LOCATION_KEY, TRANS_CREATOR, TRANS_EMAIL, TRANS_PHONE) VALUES (:location_key, :trans_creator, :trans_email, :trans_phone) RETURNING TRANS_ID INTO :ukey"
i have a program that you enter a code and your selection goes ito a richtextbox and is then added up in another as you select more items, i have run into a problem it worked a few days ago but now will not.
Dim dectotal As Decimal Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Private Sub holidaysaveButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles holidaysaveButton.Click For Each dr As DataGridViewRow In DataGridView1.Rows
I have a text file with names that have spaces and commas. For some reason when I read the file it gives me this error. Code is below. Also, I am reading the file into a combobox.
I have a form to calculate charges based on input data and charges stored in an array. When I try to save an entry to a file my program crashes and I get the error "Conversion from string "" to type 'Double' is not valid.
If rdoDay.Checked = True Then Quote.DrivingHrs = txtDrivingHours.Text Quote.WaitingCount = txtWaiting.Text
[Code].....
The error highlights the last line of the if statement beginning "Quote.TripCost" as the error, but I don't understand why..
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim product As String
[Code]....
Its says conversion from String to Integer not valid for this line: sales = InputBox("Please Enter Your Product Sales: ")
Also, when the first messagebox comes, how can I make it when you select "cancel", the programme then exits the sub routine and a second messagebox dosent come up?
I have this problem that when the textbox don't have a value I always get this error "Conversion from type 'DBNull' to type 'String' is not valid." [code]...