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
E

Edward Giles

@Edward Giles
About
Posts
12
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • One button submit that handles the work with the database
    E Edward Giles

    Clean up your code. Use ElseIf.

    .NET (Core and Framework) database question sql-server sysadmin help

  • Redundancy at its finest
    E Edward Giles

    Is the VB.NET equivalent of a float a Double (64-bit float) or a Single (32-bit float)?

    The Weird and The Wonderful csharp visual-studio question

  • Redundancy at its finest
    E Edward Giles

    I found this code in the My.Power extension for Visual Studio:

    Public ReadOnly Property BatteryPercent()
    ' This code will retrieve the BatteryLifePercent property and convert it to a percent.
    Get
    If SystemInformation.PowerStatus.BatteryLifePercent.ToString = "1" Then
    Return "100%"
    ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.99" Then
    Return "99%"
    ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.98" Then
    Return "98%"
    ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.97" Then
    Return "97%"
    ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.96" Then
    Return "96%"

    ...

                ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.06" Then
                    Return "6%"
                ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.05" Then
                    Return "5%"
                ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.04" Then
                    Return "4%"
                ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.03" Then
                    Return "3%"
                ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.02" Then
                    Return "2%"
                ElseIf SystemInformation.PowerStatus.BatteryLifePercent.ToString = "0.01" Then
                    Return "1%"
                Else
                    Return "NA"
                End If
            End Get
        End Property
    

    What idiot would write this? How about:

    If SystemInformation.PowerStatus.BatteryLifePercent <= 0 OrElse _
    SystemInformation.PowerStatus.BatteryLifePercent > 1 OrElse _
    IsNothing(SystemInformation.PowerStatus.BatteryLifePercent) OrElse _
    Single.IsNaN(SystemInformation.PowerStatus.BatteryLifePercent) OrElse _
    Single.IsInfinity(SystemInformation.PowerStatus.BatteryLifePercent) Then
    Return "NA"
    Else
    Return FormatNumber(SystemInformation.PowerSta

    The Weird and The Wonderful csharp visual-studio question

  • Running out of Memory - Maths Check
    E Edward Giles

    Try doing the computation 1 pixel at a time, and discarding results from all the iterations except 0, n-1 and n, where n is the total number of iterations in the computation so far. This would reduce memory usage by complex numbers to just 48 bytes! EDIT: Probably not 48 bytes, but 3 complex numbers need to be stored. This could be any amount, depending on the precision used.

    Algorithms algorithms performance

  • Converting a string into a method
    E Edward Giles

    If the user is going to change large parts of the code, use a ScriptControl COM component. It allows you to run a String as code.

    Visual Basic csharp data-structures testing beta-testing

  • Application with calendar menu
    E Edward Giles

    So it searches for files somewhere and places links to them into a calendar-like control(.NET MonthCalendar, perhaps?), so that the date the link is displayed on is the date of the last edit. At least that was what I understood it as.

    Visual Basic algorithms tools

  • how change level?
    E Edward Giles

    Open yourformfile.designer.vb and rearrange the initializing code, so that things that need to be displayed at the back come (in the code) before the things that need to be displayed further in front. P.S. I made a lot of assumptions.

    Visual Basic csharp question

  • A Quine in VB.NET
    E Edward Giles

    Because I was bored.

    .NET (Core and Framework) csharp

  • ERROR_SUCCESS => the successful error
    E Edward Giles

    ERROR_NOT_READY (Get a move on!) ERROR_CALL_NOT_IMPLEMENTED (Don't try to contact your friend with your laptop) ERROR_DISCARDED (you threw away your computer!) ERROR_PIPE_CONNECTED (That's an error?) ERROR_CANTREAD (Illiterate computer) ERROR_CANTWRITE (Ditto)

    The Weird and The Wonderful visual-studio com help question

  • A Quine in VB.NET
    E Edward Giles

    Bulky but it works.

    Sub Main()
    Dim data = "Sub Main()End SubDim data = ""Console.Write(data.Substring(0, 10) & vbCrLf & data.Substring(17, 12) & data.Substring(0, 29) & Chr(34) & data.Substring(29) & Chr(34) & vbCrLf & data.Substring(29) & vbCrLf & data.Substring(10, 7))"
    Console.Write(data.Substring(0, 10) & vbCrLf & data.Substring(17, 12) & data.Substring(0, 29) & Chr(34) & data.Substring(29) & Chr(34) & vbCrLf & data.Substring(29) & vbCrLf & data.Substring(10, 7))
    End Sub

    It prints out the procedure declaration as well!

    .NET (Core and Framework) csharp

  • Aaaarg....use the namespace
    E Edward Giles

    "VB (unfortunately) doesn't have this option (and please save me the C# vs. VB discussion)." It does have that option, at least in the version I've used (VB2010)

    The Weird and The Wonderful csharp c++ java php

  • creating exe
    E Edward Giles

    Here is the exact path where (project name) is the project name : %USERPROFILE%\Documents\Visual Studio 2010\Projects\(project name)\bin\debug\

    .NET (Core and Framework) csharp visual-studio 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