Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
P

philip_cole

@philip_cole
About
Posts
8
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • When you aren't even sure WHY you're writing bad code
    P philip_cole

    Our old customer service system has some brilliantly bad code in it, but I just had to share this one I spotted this morning. I think the guy got halfway through and forgot exactly what he was even meant to be fixing, let alone how to fix it.

    'ISSUE 2862 ?
    If CurrentUser.WorkingSession.Market.TaxInclusiveInCatPrice Then
    'Me.lblTotalOutstanding.Text = String.Format("{0:c}", decOutstanding)
    Else
    '?
    End If
    Me.lblTotalOutstanding.Text = String.Format("{0:c}", decOutstanding)

    I just wish we still had our old issue tracker to see what the mystical ISSUE 2862 is...

    Phil

    The Weird and The Wonderful help sales tutorial question

  • Type conversion
    P philip_cole

    Hi Robert Both ways do similar things, but it depends what the actual Type of MyValue is. (int)MyValue is casting MyValue to type int. This means that MyValue has to be an int in the first place, or a type inherited from int (which isn't possible of course!). This is a faster method, because very little has to be checked or changed in memory, but you have to know that MyValue is actually an int. Convert.ToInt32(MyValue) allows you to create an int from other types, e.g. a string like "56". This is useful if you aren't sure what type MyValue is. Because it has to work out what to do with the value tho, this method can be a lot slower than casting directly. For more info, see MSDN: Casting in C#: http://msdn2.microsoft.com/en-us/library/ms173105(VS.80).aspx Convert Class: http://msdn2.microsoft.com/en-us/library/system.convert.aspx Hope this helps Phil

    C# question

  • Problem with Database
    P philip_cole

    maybe you mean... szMyQuery.AppendFormat("SELECT User.Username, User.Password FROM [User] WHERE (((User.Username)='{0}'))", szQUser); You arent putting the value of szQUser into the sql, but literally "szQUser"! Better still, use a SqlParameter to add the username to the SQL. Hope this helps Philip Cole

    C# database help

  • get the executable name witin a console exe
    P philip_cole

    Hi Sasuko, You can use Reflection to get the file name of the exe file. You have two options: System.Reflection.Assembly.GetExecutingAssembly().Location returns the path to the file the actual code is in. So if you put this line in a class library, it will give you the .dll file. System.Reflection.Assembly.GetEntryAssembly().Location returns the path to the file which was first run to start the application. So whether you put this in your console app, or a class library it references, it will always return the path to the .exe. Hope this helps Philip Cole

    C# question

  • RichtextBox Problem
    P philip_cole

    Hi Ive not really used richtextboxes, but looking at your code, i think you just need to change the start position in richtextbox1.Find, and then use a loop: int pos = 0; while(pos < richtextbox1.TextLength) { // search for text at last position and stop if none found int index = richtextbox1.Find(message, pos, RichTextBoxFinds.None); if(index == -1) break; richtextbox1.Select(index, message.Length); richtextbox1.SelectionFont = new Font(...); richtextbox1.SelectionColor = Color.Blue; // move to end of found text pos = index + message.Length; } Hope this helps Philip Cole

    C# question database json help tutorial

  • Multi Line TextBox for Addresses
    P philip_cole

    Hi Greeky, Well the easy way is to set the AcceptsReturn property of the textbox to true. That should let them press enter onto new lines. If you want to do it manually, just change the code to the following (converted to c# from interesting vb hybrid) protected void txtAddress_KeyUp(........) { if(e.key == keys.enter) { txtaddress.Text += environment.newline; txtaddress.SelectionStart = txtaddress.Text.Length-1; txtaddress.SelectionLength = 0; } } /* NB. This may not be quite right, as my VS is ill, so didnt test it */ The two lines to note are setting SelectionStart and SelectionLength. This just says move the cursor to the last character, and make sure no text is selected. Hope this helps Philip :-D

    C#

  • How to Convert this in C#
    P philip_cole

    Hi Its not clear from the code exactly what the EnumDeviceIDS method creates ids as, but i'll assume it is a .NET string array. In which case the code should be something like: // ids is initially null; object ids = null; ScannerManager.EnumDeviceIDs(ref ids); // we now need to convert ids to an array to let us loop string[] arrids = (string[])ids; List.Items.Clear(); // our for loop can become a nicer foreach foreach(string id in arrids) { List.Items.Add(str); } /* This is all just explanation, so is commented * // signature and prototype information * EnumDeviceIDs(ref Object) * returns array of strings that contain info * 'public virtual new void EnumDeviceIDs ( System.Object IDs ) */ Hope this helps Philip :-D -- modified at 15:18 Saturday 3rd September, 2005

    C# csharp data-structures help tutorial

  • How to Convert this in C#
    P philip_cole

    [Message Deleted]

    C# csharp data-structures help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups