Why Do The Division (/) Operators Behave Differently In .NET And C#
Dec 23, 2009
If you create new projects in C# and VB.NET, then go directly in the Immediate Window and type this:
? 567 / 1000
C# will return 0, while VB.NET will return 0.567.To get the same result in C#, you need to type
? 567 / 1000.0
Why is there this difference? Why does C# require the explicit decimal point after 1000?
View 5 Replies
ADVERTISEMENT
Dec 30, 2009
Example:
Dim Sh32 As Object = CreateObject("Shell.Application")
Dim path As String = "C: empcatalog.zip"
Dim sf As Object = Sh32.NameSpace(path)
-> does not work, sf = Nothing
Dim Sh32 As Object = CreateObject("Shell.Application")
Dim path As String = "C: empcatalog.zip"
Dim sf As Object = Sh32.NameSpace(path.ToString)
Clearly path = path.ToString, but they behave differently when used as COM parameters.
View 1 Replies
Oct 15, 2011
I use some random number generators in a piece of VB.net code to simulate Gene reproduction. It works as followed:
- I generate a male chromosome that contains 46 random chromosomes which I put in the Arraylist: MaleChromosomes.
- I generate a female chromosome that contains 46 random chromosomes which I put in the Arraylist: FemaleChromosomes.
- Then I have a piece of code that randomly picks 23 chromosomes from the female arraylist and randomly picks 23 chromosomes from the male chromosomes ( Very simple simulation of reproduction ) and put these in the arraylist: Child
- I repeat this for the second child ( Arraylist: Child2.)
- Now I have piece of code that compares these arraylist to see how many chromosomes the two children share.
View 1 Replies
Feb 17, 2012
I recently installed visual studio 2010 and am using visual basic.The problem I am having is that some operators do not show up within the editor. For example the code line below
test = 3 + 5 - 6 / 7 * 4
only displays
test 3 5 - 6 / 7 * 4
the = + operators are not visible although they are there since the program will work as intended....and if I open up the .vb file in notepad everything is there. It just won't display within Visual Studio.
View 5 Replies
Mar 4, 2010
I am converting projects from C# to Visual Basic, and the namespaces in VB.NET behave in a weird way. There is some kind of hidden default namespace, and it's annoying. I want it to behave identical to C#, which works as expected - things go into the namespaces you create for them.
I've been getting around it usually with say
using MyClassLibrary;in C#, and in VB
Imports MyClassLibrary
Imports MyClassLibrary.MyClassLibrary
but it would be nice to have the functionality the same, and also logical.The other bigger problem is, I have a .tt file, and the C# project generates the code in a different namespace to the VB one.
Is there some solution to make both behave identically with regards to namespaces?
View 3 Replies
Jun 15, 2009
I am using the follwoing code to generate Menustrip at runtime.
Dim dgv1 As DataGridView
dgv1 = Me.MenuDataGridView
ReadMenuInGridView(dgv1)
Dim MItems As New SortedList(Of String, ToolStripMenuItem)
For Each dgr As DataGridViewRow In dgv1.Rows
[Code] .....
Where the sub "ReadMenuInGridView" passes the DGV by reference and populates it with the menu item from the database. My question is,, the program as it is in the form listed above works fine (where I have a DGV "MenuDataGridView" created at design time), however, if I want to make it 100% dynamic and use a DGV created at run time I will not get the menu? Actually the program will not get in to the For loop?
Simply to do that we can replace the first 2 statement with:
Dim dgv1 As New DataGridView
'dgv1 = Me.MenuDataGridView
View 5 Replies
May 21, 2012
I have created ~ 9,000 desktop.ini files, using VB code shown at
[URL]
My goal was to assign an icon to each folder of a set of folders.My problem is that the created desktop.ini files seem to behave erratically: some folders display their assigned icon, some do not.I verified that all folders and assigned icons exist.
View 2 Replies
Jan 12, 2011
I'm trying to get the 'Enter' key to behave like the tab key in a combobox control. I've placed the following code in the keypress event: If e.KeyChar = ToChar(Keys.Enter) Then NextTextBox.Focus()End If When ran, nothing happens. I've placed a break point at the 'private sub' line, and the code is not breaking. What am I doing wrong?
View 5 Replies
Feb 9, 2010
This questions is for VBers, it's irrelevant in C#.
In VB, when you create a module, all it's fucntions and members are available in the scope without need to type the module name, just like all the VB functions (Rnd, Mid, IIf etc.).
I want to create a module but I should have to explicitly write it's name to access it's members, i.e. it shouldn't be loaded to the scope like a namespace.
Update
For example, I have a Module of extension methods, I don't want all it's members to show up on the scope and in the intellisense.
I want it to be available only by instance.ExtensionMethod().
View 3 Replies
Feb 20, 2009
I'm developing with VB.NET 2008.One of my host was crashed, so I take the files and keep development on another host. But now something strange is happening:All frames, lines and shapes are disappeared on design-time, but are seen normally in runtime.
[Code]...
View 1 Replies
Apr 8, 2010
I am developing a windows desktop application and I am using vb.net 2008 Now I have 5 datagridviewcheckboxescoloumns and i want them to behave like radio button.How can i accomplish it. I made lots of search on internet to solve this problem but i couldn't so far. Actually if i had two coloumns it wont be problem i can handle it.
View 8 Replies
Jan 27, 2012
I want to implement a password text box that will behave like the one we see in Windows 7 (ie, when there is no user input, then it will display a string 'Enter password', and when the user press any key, this string is cleared). I tried all the events like 'TextChanged', KeyPress', etc., but failed to get the result.
View 5 Replies
Oct 4, 2010
I've been working on learning VB.Net from VB6 and for some reason when I use On Error Goto handlers, or On Error Resume Next the program still procs an exception and ask to continue or close.I don't really understand what I am missing, everything I've read said it's the same as VB6 with a few extra options.
View 9 Replies
Jun 8, 2011
When I view images on my development PC they look fine, but when I view them on other PC's, the images are sized differently and often get cut off. I've tested this on multiple PC's and the images always get cut off.I've attached the images from my PC and another PC to this post, the image that is cut off if from a Windows XP PC.I'm using VS 2010 on Windows 7 64-bit.
View 7 Replies
May 27, 2011
I need to create a menu bar (similar to VB6) for my ASP.NET application.
What I don't need is a standard navigation menu bar (plenty of those out there). I'm not redirecting to a different page. What i do need is a menubar that will behave similarly to a VB6 menu, or ASP.NET button control. I have to postback and execute some VB code (depending on what menu item the user selected).
View 3 Replies
Feb 27, 2009
Is it possible to make a checked list box behave like a Radio button?
View 1 Replies
Jul 8, 2011
I have a big stored procedure that I run. At the end its supposed to select a singe value to say if it succeeded or not, so I run the query as
Dim Command As New SqlCommand(SqlString, Conn)
Return Command.ExecuteScalar()
Which works. However there is an error in my stored procedure. I know its causing an error because the logic in the stored procedure rolls back the transactions, and after the Execute Scalar call, my transaction count is down to 0 and the my data hasn't changed. However no SQL exception was generated.
The strange part is, I changed the code to grab all the result sets from the SP to see if I could get more information. So I called the same SP like this,
Dim DAObj As SqlDataAdapter = New SqlDataAdapter
Dim CommandObj As SqlCommand = New SqlCommand(SQLString, Conn)
DAObj.SelectCommand = CommandObj
Dim DS As New DataSet()
DAObj.Fill(DS)
When I run this, with the exact same sql as before, executing the exact same stored procedure, this time I get an SQL exception because one of my nested SP calls was missing required parameters. So what could cause this? Why would running it one way produce an error and the other way have the error but not report it? Is the difference on purpose, or some kind of obscure bug in ADO.Net?
View 2 Replies
Jul 4, 2009
I have a web application that works in our stage/test environment fine but once we moved it to our production environment something weird happens. All the control ids change. a label went from ctl00_cphMainContent_lblPetName to _ctl0_cphMainContent_lblPetName. Why would this happen? What could cause something like this to happen. The only two differences I know of are the production environment has HTTPS and I've disabled debugging.
View 3 Replies
Apr 5, 2011
I'm working on a website that creates pdfs dynamically.I've been playing around with two different pdf controls- wpcubed and abcpdf, and was surprised to see that they both appear to render text differently.
wpCubed:
abcpdf:
They are both using arial 25pt bold, so I was expecting them to look identical. Can anyone explain why they don't. Here are the full files: wpCubed , abcpdf
View 1 Replies
May 22, 2010
What is the most timers you have used in an application? I think the most I have ever used is 2.In another forum this question was asked. "I have a Timer ... I have a situation where I want to run the code in the Tick event ONLY ONCE not on the interval i have the timer set too."
I responded with Timer1_Tick(New Object, New System.EventArgs) Which led to this "The 'sender' object is VERY important when you have more than one Timer being handled by the Tick event procedure. This is because in a multi-timer tick event procedure, the only way your program knows which timer just fired is by querying the 'sender' object.When you use code like this you are putting nothing into the 'sender' object, so that if you were ever going to query it a 'kaboom' is going to happen.""...this 9 timer Tick event handler job done. Remember, all that is required is the correct timer name gets put into the ListBox." "The need for multi-timers to be handled by a single Tick event handler happens all the time. How would a real life programmer handle this? "Oh, to test the "kaboom" theory I wrote this and ran it overnight successfully:
[code]...
View 33 Replies
Sep 4, 2011
msgbox(System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList(0).ToString())
is showing Ip address in Win XP but in Windows 7 it is not showing.
View 7 Replies
Feb 25, 2011
I have a datagridview I am displaying on a form and would like to format one of the columns differently then the available formats. I have a column that is a decimal(18,2) (in the table) named "MyDecimalField". In asp.net I could do this, in the "template field" of a datagrid.
math.round(MyDecimalField / 60 , 2)
In VB.net forms I cant figure out how to do that. Basically I need to divide the cell by 60 and round that to 2 decimal places.
IE
the Cell contains this: 1283.93
I want the user to see this: 21.40
1283.93 / 60 = 21.3988333 then round it to 21.40
View 1 Replies
Jan 3, 2011
I have written some code in a form which is shown via ShowDialog from a different form. This code fills a DataGridView with data from two tables in a dataset, one through data binding, and one through more manual means. The latter part runs, or more accurately, fails to run in the same way if I call this form in the same way subsequently but without stopping debugging.
View 2 Replies
Jul 22, 2009
I am creating a program that I would like to distribute. I am using printform in VB 2008 to print my form. My form is the size of my computer screen...15 in. If the program is run on a different computer with a different screen size, will it affect the appearance of the form on the screen or the printing of the form? If the form is run on a laptop, for example, with a smaller screen, will it cut off my form and thus cut off the form during printing? Will a bigger screen increase the size of the form and not allow it to fit correctly when printed? I was just curious and wondering.
View 6 Replies
Apr 3, 2011
When I use IE8, it displays the page fine, but when I use the web browser control in VS 2010, it shows the page differently (in a bad way).
View 12 Replies
Dec 3, 2010
What's the difference between / and for division in vb.net? My code gives very different answers depending on which I use. I've seen both before, but never knew the difference.
View 3 Replies
Feb 24, 2011
I am using oledbconnection object with access database engine 64 bit to get data from Excel file. While using sqlconnection object if sql string has these statements "SET ARITHABORT OFF;SET ANSI_WARNINGS OFF;" , then division by zero exception doesn't cause any problem. But while using oledbconnection these statements cause error. My code samples are below:
Dim PbpConn As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=C:BuzBeatDataPBPData.xls" & ";" & _
[Code]....
When SUM(pbA) has value "0" then it causes error and can't get data. is there a way to close the warnings and division by zero exceptions?
View 6 Replies
Nov 25, 2011
This is driving me round the bend. I'm a long time VB.NET forms developer, quite new to ASP.NET and completely new to MVC. I'm creating vbhtml pages that use the VB.NET razor syntax, and I seem to be constantly fighting against the UI which is trying to indent my code incorrectly. Take the following example, based on the template page for a new Razor view:
@Code
Layout = Nothing
End Code
[code].....
View 2 Replies
Aug 12, 2009
I have a small VB. app in VS2008 that opens a windows folder in maximized view.I am using the following code:
Dim startInfo As New ProcessStartInfo("explorer.exe")
startInfo.WindowStyle = ProcessWindowStyle.Maximized
startInfo.Arguments = "C:\Program Files\123 Systems\ExcelFolders\TechTimeSheet"
Process.Start(startInfo)
When using my app with windows xp it works well. It opens a single folder as if going through the "my computer" to open it. Attached is a screen shot "folder" to show the desired way.However when using the same code with Vista it opens my folder as if I right clicked on the start menu and selected "explore", also a screen shot named "explore" is attached showing what I do NOT want. What should I change to get both vista and XP to work the same, that is opening a single folder.
View 1 Replies
Sep 1, 2009
I have a legacy vb6 application that uses a shell command to launch a newer .net application. It's a very simple command, just launches an app. Here's the problem. When I run the .net app through the shell command, it tries to connect to a database that is not referenced in it. If I double-click the .net executable, it runs just fine and connects the way it is supposed to. Normal, no problems. Only when I run it from the shell command do I have problems. I have checked everything I can think of and simply can not come up with a reason why the app would behave differently when launched from a shell command.
View 3 Replies