|
yes u can call this method in class constructor and store the value in variable
and then can use that variable to pass in other methods.
rahul
|
|
|
|
|
Hi,
Kindly help me to convert following lines into c#:
Private Declare Function GetPixel Lib "GDI32" (ByVal hDC As Long, ByVal XCord As Long, ByVal YCord As Long) As OLE_COLOR
Private Declare Function GetWindowDC Lib "USER32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseDC Lib "USER32" (ByVal hwnd As Long, ByVal hDC As Long) As Long
Private Declare Function GetDesktopWindow Lib "USER32" () As Long
Thank you
|
|
|
|
|
Hi,
To convert any VB code to c# this link is very usefull:
//www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx
well C#conversion of your VB code will be following:
[System.Runtime.InteropServices.DllImport("GDI32")]
private static extern OLE_COLOR GetPixel(long hDC, long XCord, long YCord);
[System.Runtime.InteropServices.DllImport("USER32")]
private static extern long GetWindowDC(long hwnd);
[System.Runtime.InteropServices.DllImport("USER32")]
private static extern long ReleaseDC(long hwnd, long hDC);
[System.Runtime.InteropServices.DllImport("USER32")]
private static extern long GetDesktopWindow();
|
|
|
|
|
|
Is the original code VB6 or VB.NET?
If it's VB6, then the equivalent C# code will need the long's changed to int's since VB6 Long is the same size as C# int (or VB.NET Integer).
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: C# to C++ converter, VB to C++ converter
Instant Python: C# to Python converter, VB to Python converter
|
|
|
|
|
Hi,
I need to know the Language name of following code:
0001100000110000111100011110011001101100111111111110000111000010000000 <<= what is the language name of said code?
Thank you
|
|
|
|
|
|
Thank you sir,
is there any method to convert from binary to string?
|
|
|
|
|
If you are sure that that binary sequence represents a piece of code, then you should read the documentation describing the assembly instructions of the processor family that the machine executing this code belongs to.
The fist x bits(x can take different values) represent the opcode of the assembly instruction. If you know the opcode, you can quicly find the name of instruction. The other bits represent addressing modes and operands.
Good luck!
|
|
|
|
|
Hi,
I need to convert a string of 16 chars "0123456789ABCDEF" to 8 bytes x'0123456789ABCDEF' in c#.
Can anyone help me with this?
Thanks
David
|
|
|
|
|
string s = "0123456789ABCDEF";
Int64 i = Int64.Parse(s, NumberStyles.HexNumber);
byte[] b = BitConverter.GetBytes(i);
Console.WriteLine("0x{0:X}", i);
|
|
|
|
|
Hello,
I have created a Window Application using C#. Now I would like to create an installation package out of it which I can pass it to friends and families to install it on their computer and give it a try.
I have learnt that I can follow publication steps "Build -->Publish" and make use of the Publish Wizard to create installation package.
My google search made me aware of the following software:
1- WiX installer
2- Nullsoft Installer
3- MSI Installer Tool
4- Inno Setup
which apparently are meant to be Windows Installer authoring tool.
Now I am very confused and would appreciate if someone can tell what is going on and what I need to use in order to create a single installation file.
Thank you very much and have a great day.
Khoramdin
|
|
|
|
|
First You've to compile your code in release version.
Now Add installer project;
In installer properties you specify to install dotnet framework with your application.
In short:
Needs for application installation are:
Windows installer 3.1
Dot Net FarameWrok 2.0
Application MSI or EXE installation file.
thats all. You've to install the written all packages one by one in the same order.
God Bless you.
Syed Shahid Hussain
|
|
|
|
|
Hello I am an newbie in C# and I am making a program for our office and need to develop a class in c# that I can use for a login form. The table I have is very simple for username and password. It has a UserID which is a primary key and a password I dont care about the username just as long as they type in the right password. I also have a bool column that is IsLoggedIn. I have to set the IsLoggedIn in the table to true once the password has been typed in right. There will only be 4 possible logins or passwords.
I have a connection to the database like this:
public static void Login(String LoginBox)
//{
// string strConn, strSQL;
// strConn = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Documents and Settings\admin\My Documents\Visual Studio 2005\Projects\GasCabinetSimulator\GasCabinetSimulator\GasCabinet.mdf;Integrated Security=True;User Instance=True";
// strSQL = "SELECT UserID, PassWord, IsLoggedIn FROM tblLogin";
// using (SqlConnection cn = new SqlConnection(strConn))
// {
// try
// {
// cn.Open();
// }
// catch (SqlException ex)
// {
// MessageBox.Show("Connect Attempt Failed");
// MessageBox.Show(ex.Message);
// return;
// }
// using (SqlCommand cmd = new SqlCommand(strSQL, cn))
// {
// try
// {
// using (SqlDataReader rdr = cmd.ExecuteReader())
// {
// while (rdr.Read())
// if (LoginBox == rdr["PassWord"].ToString())
// {
// MessageBox.Show("Login successful","Login Success",MessageBoxButtons.OK,MessageBoxIcon.Information);
// //rdr["IsLoggedIn"] = true;
// }
// rdr.Close();
// }
// }
// catch (SqlException ex)
// {
// MessageBox.Show("Query failed");
// MessageBox.Show(ex.Message);
// return;
// }
// }
// cn.Close();
However it is readonly and I cant change the IsLoggedIn column and I get a box for each username or password until it is either the right one or the wrong one totally.
Allan F. Gagnon
|
|
|
|
|
You should do a select count(*) where the username and login equal the values that were entered
That means only the data layer ever knows the real values.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I am sorry but I am not sure what you mean. Should I change my select statement to a Select Count?
Sorry
Newbie still learning!!
Allan
Allan F. Gagnon
|
|
|
|
|
Yes. You shouldn't ask the database to tell you all the passwords. You should tell the DB what username and password you were given, and have it tell you if it's a valid pair.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thank You
Allan F. Gagnon
|
|
|
|
|
hello All,
The template field in gridview has a html table which is binded to datasource from sql server all the data is displayed fine my question is, is it possible to display the data in two columns instead of one column, if Yes how is it done. Please see below for code, Any suggestions are appreciated.
<itemtemplate>
" width="100" height="100" border="0"> | | $<%# Eval("Price") %> | | <%# Eval("ProductName") %> | |
Thanks in Advance for your help. Best Regards
|
|
|
|
|
Hi,
I have two projects in VS2005 that seem to run differently and I don't know why?
Psuedo code situation:
Windows Form - On_Load
read database
set radiobutton.checked = true/false depending on value in database field.
Windows Form - click radiobutton event
change to true/false in database.
The problem I am having is that in one project the click event is not being fired on loading but in the other it is fired. I don't want the click event fired at loading.
I have spent hours on this and am no closer to resolving the issue
Any suggestions on where to look for the difference in the two programs will be appreciated.
Glen Harvy
|
|
|
|
|
Hi,
the question is not clear yet. What click event ? or do you mean a CheckedChanged event?
I suggest you give your programs a name, and probably show some relevant code for each.
Luc Pattyn
|
|
|
|
|
For given array of objects, I need to produce a another list or two-dimensional resulting array or something where each pair of values consists of a one unique element from the original array and the number of times that element appears in original array.
Tried google, but as usual... of about 100 results none is even close to what I need.
I know this is trivial... but again... I'm trying it for 3 hours and no solution...
|
|
|
|
|
Hi,
you could create an empty hash table and enumerate your collection:
- use your item as a key
- first test if the key already exists in the hash table
- if not, add a (key,value) pair with value=1
- if yes, modify the entry with that key to become (key, old value + 1)
Et voila.
Luc Pattyn
|
|
|
|
|
Great, got some solution on my own finally... though this sound better... I'll post mine in a so you can laugh bit...
but it does work...
<code> class Program
{
static void Main(string[] args)
{
ArrayList ResultList = new ArrayList();
int[] repeatCount = new int[5];
object[] originalObjectArray = new object[5];
Console.WriteLine("Enter array");
for (int i = 0; i < 5; i++)
originalObjectArray[i] = Console.ReadLine();
ResultList.Add(originalObjectArray[0]);
repeatCount[0] = 1;
int passCount = 0;
foreach (object o in originalObjectArray)
{
if (passCount > 0)
{
bool upis = true;
for (int i = 0; i < ResultList.Count; i++)
{
if (ResultList[i].Equals(o))
{
repeatCount[i] += 1;
upis = false;
}
}
if (upis == true)
{
ResultList.Add(o);
repeatCount[ResultList.Count - 1] = 1;
}
}
passCount++;
}
for (int l = 0; l <ResultList.Count; l++)
Console.WriteLine("Broj ponavljanja elemnta " + ResultList[l].ToString()
+ " je " +repeatCount[l].ToString());
}</code>
BTW how do I test if key is already in Hashtable?
|
|
|
|
|
Hi,
I did not laugh, but I was amazed about the complexity you introduced.
Will you ever feel sure this is correct ??
Some detailed remarks:
1) your code can handle no more than 5 objects, there is no need for such a limitation
2) I did not like the name "o" for one of the objects; I avoid single-character names
except maybe for local int counters; for real objects, I use real names.
3) you did the first object outside the for loop, then needed extra stuff
(passcount>0) to skip it inside the loop; better do everything inside the loop
But in the end, you followed the approach I suggested.
Did you realize you are relying on the fact that ArrayList preserves the order
of the elements added (unless you instruct it otherwise, e.g. Sort) ?
When using a hashtable, you dont need such assumption: it is intended to keep
key,value pairs together (as opposed to your code trying to keep an ArrayList and
an int array in the same order).
The test you need is Hashtable.Contains()
May I suggest you take some time to read up on collections (mainly ArrayList
and Hashtable). They are powerful tools that can be applied on many occasions,
requiring less code (and hence offering less room for bugs).
Regards.
Luc Pattyn
|
|
|
|