Nyasha's Q&A profile
Visual Studio Express Editions after doing a division the value becomes zero (i think because of an endless numbers of decimals
HP and MaxHP start each out with 999999, but once the HP gets changed to for example 999253 label1.text shows 0(it should be 99 -> (999253 / 999999)*100 = 99,9253and so on, can someone help me out pls hmm while typing this and seeing on the calculator that there is an endless number of decimals -> is this the prob so is there a way to make it a round number (100 instead of 99,9253and so on) This is my code: private void hPLabel3_TextChanged( object sender, EventArgs e) { int HP = Convert .ToInt32( this .hPLabel3.Text); int MaxHP = Convert .ToInt32( this .hPLabel4.Text); int Procent = (HP / MaxHP) * 100; label1.Text = Convert .ToString(Procent); HealthBar2.Image = Image .FromFile( &q ...Show All
.NET Development SerialPort DataReceived Timeout?
I'd like to get better control over when DataReceived are generated while using System.IO.Ports.SerialPort. In particular, I want to be able to control the timeout behavior. This can be done using SetCommTimeouts() when writing to the Win32 API but so far I have not found anything equivalent under .NET Anyone know how this might be done I was thinking I might be able to control it using IOCTL_SERIAL_SET_TIMEOUT but have not been able to find a way to access the underlying filehandle. Is there a way The ReadTimeout property uses SetCommTimeouts(). However, it does not apply to the DataReceived event. Only when you make a blocking call to one of the Read*() methods. A Read() method call is usually only p ...Show All
Visual C# How to Update StatusBar Pannel
Hi, I want to update one of the Pannels within my statusbar, but I'm not sure how to reference the pannel I want. Can someone point me in the right direction, or know of an example Thanks Regards, Andrew You can just set the Text property of the StatusBarPanel you have added to it. _myStatusBar.Panels[0].Text = DateTime.Now.ToShortTimeString(); ...Show All
Visual Studio 2008 (Pre-release) Error: Mapping not found in workspace
I just start a new model from a simple database and receive this error when I try manipulate some data: The mapping for Entity Container 'ADONextLib.ADONext' was not found in Workspace. The samples from the CTP is working properly. There is a connectionstring in a .config file called "ADONextLib.ADONext" A suggestion to help out here: You can keep related metadata files in a separate directory and load them up at runtime. This allows you to for example, share the same metadata files accross solutions, or can help you to manage different metadata files for different projects in one location. We'll have better ways to manage these files in future CTPs. ...Show All
Windows Forms Non background image on a label.
I want to show a little graphic directly to the left of a piece of text in a windows forms applications. The System.Windows.Forms.Label control seems like the obvious place to go for this... I create my Label control and set the .Image property to my image and set the ImageAlign property to MiddleLeft. Unfortunately, the image is underneath the text... not adjacent to it... not exactly what I wanted. (Nor what I expected since other controls, like Panel, call the property BackgroundImage if it is going to be painted under everything else). Then I think... no problem... the same thing happens in System.Windows.Forms.LinkLabel, and I know the solution. I am using a 16px image, so I set the left padding on the Label to be 16. (This works f ...Show All
.NET Development Soap Extension ChainSream method
Hello, I use the soap extension to log the request and response soap messages in my web service like documented in the MSDN: http://msdn2.microsoft.com/en-us/library/7w06t139.aspx it works fine with no problem but i want to understand: why we should finally copy the stream from the memory stream to the oldstream. First at the beforedeserialize stage we copied the stream to the memory stream and in the chain stream we returned the memorystream, in the afterserialaization stage i got the serialized message from the memory stream, this means that the .Net framework worked on the memory stream so the serialized message was written on it, so why the response to the client wasn't sent from memory stream, why should i copy it from the ...Show All
.NET Development Selecting a node with XPath...
Hi all, I am completely new to manipulating/navigating Xml with XPath so please excuse my ignorance. I am trying to manipulate an MS Word ML document and have hit a problem at the first hurdle. The first thing I need to do is get the children of the w:body element. The start of the Xml document is as follows: ... < xml version="1.0" encoding="UTF-8" standalone="yes" > < mso-application progid="Word.Document" > <w:wordDocument xmlns:w=" http://schemas.microsoft.com/office/word/2003/wordml " xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl=" http://schemas.microsoft.com/schemaLibrary/2003/core " ...Show All
SQL Server vb or vb.net
Hi....I just have two simple ( ) questions: The first: Is te following code written in vb.net or vb The second: Do I really need a redirection to "wrong.aspx" in the try-catch..because when will it be executed ...I think the code work... Here is the code: Sub Spara( ByVal obj As Object , ByVal e As EventArgs) Dim ConnectionString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Databas1.mdf;Integrated Security=True;User Instance=True" Dim strSQL As String = ( "INSERT INTO MyTable ( City ) VALUES ( @City )" ) Dim Conn As New SqlConnection(ConnectionString) Dim Command As New SqlCommand( "" , Conn) Command.CommandText ...Show All
Windows Forms ListView Column Widths Question
Hi folks, I'd like to retrieve the current width of a column in a ListView, except I'm having troubles figuring out how to get the column I want to work with. My WinForm is using C/C++ - advice -Zero Hi nobugz, When I use the proper syntax (as you pointed out above), I receive the following compiler errors: error C2845: '[' : cannot perform pointer arithmetic on __gc pointer 'System::Windows::Forms::ListView::ColumnHeaderCollection __gc *' error C2227: left of '->Width' must point to class/struct/union The line of code now looks like: int iWidth = listViewLogWindow->Columns[0]->Width; -Zero ...Show All
Visual C# still not getting communication between classes
alright, let me try and explain this: I have a main class that creates new instances of two other classes (class 1, class 2) "class 1" needs to do a lot of work with info from "class 2", but unfortunately can't access it. I could pass it all in as parameters from the main class (which obviously can acess both "class 1" and "class 2" as it created them), but this would be insanely difficult ( due to how much stuff it works with). I thought that i could simply create a public version of class 2 in the code for the main class by saying public classname Class2 ( get { return class2; } set { class2 = value; } ) I then tried to access "class 2" in "class 1"'s code by saying main ...Show All
Visual C# extracting data from comma delimited string
hi, im using c#, have a comma delimited string and i wish to split it. string example is: john smith, freddy, mark/,jones, john i don't wish to split where a comma is backslashed. any ideas thanks. Hi, you didn't write how you want your string to be split... anyway, how about this piece of code...: string values = "TechRepublic.com, CNET.com, News.com, Builder.com, john/, smith, GameSpot.com" ; string [] arrayOfValues = values.Split( new char [] { ',' , ' ' }, StringSplitOptions .RemoveEmptyEntries); Andrej ...Show All
Visual C# how to endure only one object instance exists
i am adding a user control to a form programmatically but before i do i want to check if that control already exists, if it does exist i will instead just make it the active/visible control. How can check to see if a control already exist and how can i find a reference to it and make it active/visible Do you mean just one object per form Or one for the whole application E.g. if you have two forms, and Form1 already contains an instance of your control, and you try to add it to Form2, what do you want to happen Do you want Form1 to be brought to the foreground and the control to be made visible Or do you want to permit up to 1 control per form If it's one per form, then you'll need to iterate through ...Show All
Game Technologies: DirectX, XNA, XACT, etc. Texture diffusing...
Hi all - my question is how can I get textures when drawn not to diffuse. This happens when the destination rectangle is bigger than the source rectangle - instead I just wnat to "magnify" the image...stretching the texture out horizontlaly, vertically, or both. With everything I try I either get diffusion (i.e. the image fades as it is stretched, making it semi-transparent), or I get pure black. :S Please tell me what I need to do if possible - thanks very much. Alex Ok at your request here it is: Loading: ' Load bitmap texture from embedded resource. Dim bitmapCreationParams As New TextureCreationParameters( _ 0, 0, 0, 1, _ _graphicsDevice.DisplayMode.Format, _ ResourceU ...Show All
.NET Development Exception on Application.Exit()
Hello, when my application shuts down via Application.Exit() I get a message box with the text ["unknown software exception" 0x80000003 on .....]. In the application I use DirectShow (via directshow.net) and managed DirectX. Besides that I start a tcp listener in a seperate thread but gracefully close it via thread.join(number of milliseconds). This exception did not pop up 5 days ago. Does somebody know where I can look at when debugging or just a few hints where too look at in the internet or sdk Thanks in advance, Armin You can use the Debug Diagnostics Tool from the IIS Diagnostic Toolkit to capture a memory dump during a crash. But if you have the code - Run in debug and stop on fir ...Show All
.NET Development Get data from database
i want to have a button and textbox on my form and when i type in a username and click the button i want a lable to show what the password is for that username. the connectionstring would be typically like this: "Data Source=.;Initial Catalog= DatabaseName ;Trusted_Connection=true;" so... New SqlConnection( "Data Source=.;Initial Catalog= DatabaseName ;Trusted_Connection=true;" )) if you are using SQL Express then change the data source to: "Data Source=.\SQLExpress..........." www.connectionstrings.com has all the connectionstrings for your needs. the connection string is basically a string that contains details on how/where to connect to to ac ...Show All
