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
A

AaronM_NZ

@AaronM_NZ
About
Posts
30
Topics
14
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • What a gem.
    A AaronM_NZ

    And found another similar bit of work (done in Perl, so may be 'leigt'?) http://pastebin.com/TiyDDuPp[^]

    for ($loopCount=0; $loopCount <= $stringLength; $loopCount++) {

                $char = substr($inputString,$loopCount,1);
                   if ($char eq 'a') { $char = uc($char); }
                elsif ($char eq 'b') { $char = uc($char); }
                ...
                elsif ($char eq 'z') { $char = uc($char); }
                else { $char = $char ; }
                $outputString = $outputString . $char;
        }
    

    return $outputString;

    The Weird and The Wonderful ruby com

  • What a gem.
    A AaronM_NZ

    Stumbled across this gem today. http://pastebin.com/4Nx8yggU[^] For preservation sake, here is a snippet, but you get the idea:

    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%"
    ... etc

    Wow is all I can say.

    The Weird and The Wonderful ruby com

  • Microsoft asking for my hosting credentials?!?
    A AaronM_NZ

    Yes - and the thing with WebMatrix[^]is its a very 'next, next, finish' type product - ie I wouldnt have to ever know what a web.config file is if I didnt want to, or how to FTP my website up, it does the lot. I was quite interested in the stand alone SQL CE engine[^] but alas it didnt work....

    The Lounge com hosting beta-testing question code-review

  • Excitement behind Azure
    A AaronM_NZ

    I was in the same camp as you, but after going along to the Microsoft launch event here in NZ a few months back I can see there are some quite good things you can do with cloud computing. I wouldn't use it myself (currently anyway), but if you ran say a online ticketing website it would be beneficial in that you can ramp up to as many servers as you want/need (budget pending of course) should you know that there is going to be a massive load on your servers at 9am when a particular concert goes up for sale. A local company (www.greenbutton.net[^]) also showed how you can do 3D image rendering for a small price but a lot quicker than any home PC could manage (ie minutes rather than hours) And the other example they gave was a start up company which didnt want to invest $000's of dollars in server hardware, just to have their start up fail and be left with all servers/equipment lying around. Or maybe, Microsoft are just really good at giving a sales ptich....

    The Lounge cloud question

  • Microsoft asking for my hosting credentials?!?
    A AaronM_NZ

    Understandable, but I would think Microsoft would have access into the worlds largest hosting company! I have a few free hosting accouts avialable via GoDaddy, so I will set one of them up for MS to do their testing, thus keeping them away from my live websites. Last thing I would want is to make a change to the web.config at the root and stuff up everything!

    The Lounge com hosting beta-testing question code-review

  • Microsoft asking for my hosting credentials?!?
    A AaronM_NZ

    Is this normal? I have a connect ticket open at Microsoft [^] for their WebMatrix product. There is a comment at the end asking for a temporary password to my hosting provider for a microsoft.com email address - really? I could set up a temporary user for him, but seems very odd to me that such a big company is asking for some credentials. Might as well give him my internet banking logon as well!

    The Lounge com hosting beta-testing question code-review

  • jQuery Novice to Ninja for free!
    A AaronM_NZ

    http://sale.sitepoint.com/index.php[^] Was just considering buying this book to, no need now!

    The Lounge javascript php database com learning

  • How to split a string the hard way (VB6)
    A AaronM_NZ

    It took me about 20 minutes to work out what the heck this For/Next loop was doing. The programmer must not have heard of .Split. It takes a key from an INI file (vkeys) and if it is formatted as such: SERVICES = Service1, Service2, Service3, Service4 ... it puts the list of services into an array for later use..

    If vkeys(lval, 0) = "services" Or vkeys(lval, 0) = "SERVICES" Then
    totallength = Len(vkeys(lval, 1))
    For searchstring = 1 To totallength
    tempcounter2 = tempcounter2 + 1
    If Mid(vkeys(lval, 1), searchstring, 1) = "," Then
    servicecount(X) = servicecount(X) + 1
    nodeservices(X, servicecount(X)) = Mid(vkeys(lval, 1), _
    tempcounter1, tempcounter2 - 1)
    If Right(nodeservices(X, servicecount(X)), 1) = "," Then
    ' This strips the comma of the end of the string.
    nodeservices(X, servicecount(X)) = _
    Left(nodeservices(X, servicecount(X)),_
    (Len(nodeservices(X, servicecount(X))) - 1))
    End If

            'Sets start of service name within string
            tempcounter1 = searchstring + 1
            tempcounter2 = 1
        End If
        If searchstring = totallength Then
            nodeservices(X, (servicecount(X) + 1)) = Mid(vkeys(lval, 1),\_
                         tempcounter1, tempcounter2 - 1) ' Gets the last service.
        End If
    Next searchstring
    
    servicecount(X) = servicecount(X) + 1
    tempcounter2 = 1
    

    End If

    The Weird and The Wonderful data-structures tutorial

  • So I was on Facebook today...
    A AaronM_NZ

    I have had that before, someone from years ago was in my friends suggestion list, but has no links with any of my current friends. All I can think of is that she searched for me (my profile is hidden - well I think it is...) and it's come up on my list. Which is quite disturbing if that is the case, as who knows where I am appearing on Facebook... Might have to have a close read of the T&C's, but I bet they are rather long and tedious...

    The Lounge question lounge

  • Classic ASP and 'AJAX', and a database update
    A AaronM_NZ

    I have an old classic ASP app that I am trying to do some AJAX on (the real way, not Microsoft .Net way). I have a couple of DIVs that are alternated from hidden to visible (depending on if its an UPDATE or READ), which are controlled by a href='#' and an ONCLICK call to some javascript to do the hiding/displaying. My question is, whats the best approach to trigger a database update back when the hyperlink is clicked for the update? Should I be changing the hyperlink to a form button, or have a full form hidden and displayed, rather than just a hyperlink? Just looking for an approach, dont need actual code. Here is a brief sample of the code I am working with. Note its in a Do..Until loop and returns a few hundred entries back from the database. showHide simply swaps the display: setting, and changeHTML changes the innerHTML of the control passed to it.

    <script type="text/javascript">
    function showHide<% Response.Write unqID %>()
    {
    unqID = '<%Response.write unqID %>';
    showHide('Comment' + unqID);
    showHide('ExpandComment' + unqID);
    if(document.getElementById('Edit' + unqID).innerHTML == 'Update')
    {changeHTML('Edit' + unqID,'Edit...');}
    else
    {changeHTML('Edit' + unqID,'Update');}

     }
    

    </script>

    <a href="#" id="Edit<%Response.write curATMID %>" onclick="showHide<%Response.write unqID %>(); return(false);" class="Comment">Edit...</a>

    <div id="<%Response.write "Comment" & unqID %>">
    <% Response.Write "<b>" & Trim(db("Comments")) & "</b>" %>
    </div>

    <div id="Expand<%Response.write "Comment" & curATMID %>" style="display:none">
    <textarea id='cmtUpdate<%Response.write "Comment" & curATMID %>' type='text'
    style='width:100%; height=60px;'
    rows='4' cols='100'>
    <%Response.Write Trim(db("Comments")) %> </textarea>
    </div>

    Web Development database question csharp javascript tools

  • When does 3 Nov = March 11?
    A AaronM_NZ

    I am building a string value of concatanated dates for updating to a SQL database, so thankfully I dont have to actually write the dates to the sheet, but I thought I would so I could see what was going on, it just slowed me down and fustrated the heck out of me! The DB is updating correctly, and I am just adding a space to the front of the cell so it doesnt think its a date and then kindly reformats it. Still very annoying, especially when I am specifically stating the month as text and the date format....

    Clever Code question

  • When does 3 Nov = March 11?
    A AaronM_NZ

    Always according to Excel/VBA I have been working in VBA for the last month or two, and it is really driving me spare! This one has been fustrating me today, after getting some strange results I made the following sub:

    Sub Test()
    Dim aryDates(0) As Date

    aryDates(0) = "03-Nov-2008"
    
    ActiveCell.Value = ""
    For z = 0 To UBound(aryDates)
        ActiveCell.Value = ActiveCell.Text & Format(aryDates(z), "dd-mm-yyyy")
    Next
    

    End Sub

    One would think the result (here in NZ) would be 03-11-2008, but alas Excel thinks I want all my dates formatted in US format, despite my regional settings being set to EN-NZ, and makes the cell value 11-03-2008.... Even after specifically making the month format mmm. Gahh!!

    Clever Code question

  • Active Directory Computer Groups in VBA
    A AaronM_NZ

    I have found the answer, based on this post - http://www.tek-tips.com/viewthread.cfm?qid=1245332&page=1[^] My resulting code now looks like this, in case anyone else is interested:

    Sub TestHarness
    Set objTrans = CreateObject("NameTranslate")

    objTrans.Set 3, "_<domainname>\\<servername>_$"
    strComputerDN = objTrans.Get(1)
    
    Set objComputer = GetObject("LDAP://" & strComputerDN)
    colGroups = objComputer.MemberOf
    
    For i = 0 To UBound(colGroups)
        ActiveCell.Value = GetGroup(colGroups(i))
        ActiveCell.Offset(1, 0).Select
    Next
    

    End Sub

    Function GetGroup(strGroup) As String
    z = Split(strGroup, ",")
    If Left(z(0), 3) = "CN=" Then
    GetGroup = Right(z(0), Len(z(0)) - 3)
    Else
    GetGroup = ""
    End If
    End Function

    Visual Basic csharp windows-admin question

  • Active Directory Computer Groups in VBA
    A AaronM_NZ

    So I have to do some code in VBA (if only it was .Net I wouldnt be here!) to get a list of all the groups a COMPUTER object is in from Active Directory. I can do this easily with ADS and a user, but the IADsComputer object does not have groups with it. Any idea how I could do this? The following works for users (in Excel)

    Sub testHarness()
    'Dont forget to add reference to Active DS Type Library

    Dim usr As ActiveDs.IADsUser
    Set usr = GetObject("WinNT://_<domainname>_/_<username>_,user")
        
    For Each oGroupIn usr.Groups()
        ActiveCell.Value = oGroup.Name
        ActiveCell.Offset(1, 0).Select
    Next
    

    End Sub

    I would think that the following would work for Computers, but alas it does not :mad:. I have been hunting for examples all day, but I can only find .net ones (which all work perfectly!)

    Sub testHarness()
    'Dont forget to add reference to Active DS Type Library

    Dim srv As ActiveDs.IADsComputer
    Set srv = GetObject("WinNT://_<domainname>_/_<servername>_,computer")
        
    For Each oGroup In srv.Groups()
        ActiveCell.Value = oGroup.Name
        ActiveCell.Offset(1, 0).Select
    Next
    

    End Sub

    Or do I need to do this completly differently? (And I really hope this is the right forum for VBA, I couldnt see anything else)

    modified on Tuesday, January 13, 2009 7:05 PM

    Visual Basic csharp windows-admin question

  • Determining if a GPS point is inside a polygon
    A AaronM_NZ

    Thanks very much for this, I think I expected the C code to perform the same as the Fortran code, but it obviously does not. Thats ok, its sufficient for what I need it for. And thanks for the VBS code, its helped. I asked another developer here and he said that 'c = !c' in C (the language..) is not the same as 'c = Not c' in VB - it should be 'c = 1 - c' to get the 0,1 result. But I like your approach and making it boolean, I think my head was stuck too much in the detail, and needed the 2nd, detatched opinion. Ive been buried in trying to understand GPS and all the maths required for the last week, and it was starting to do my head in! Really appreciate the help, thanks a lot!

    C / C++ / MFC html

  • Determining if a GPS point is inside a polygon
    A AaronM_NZ

    I knew I should have listened more during maths at school! Thanks for those links, with them and the next comment, I think I have worked it all out. Appreciate the help.

    C / C++ / MFC html

  • Determining if a GPS point is inside a polygon
    A AaronM_NZ

    Sorry if this is in the wrong forum, but I didnt think it would fit in the others! I have been attempting to convert a small bit of C to VB from this site: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html[^] It determines if a given point is either inside, outside, or on the edge, of a polygon shape. I want to use this in a GPS mapping application I am working on, but its not working, I think I have some of the syntax slightly wrong. The code to convert:

    int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
    {
    int i, j, c = 0;
    for (i = 0, j = nvert-1; i < nvert; j = i++) {
    if ( ((verty[i]>testy) != (verty[j]>testy)) &&
    (testx < (vertx[j]-vertx[i]) * (testy-verty[i]) / (verty[j]-verty[i]) + vertx[i]) )
    c = !c;
    }
    return c;
    }

    Here is what I have converted it to:

    Function pnpoly(ByVal nvert As Int16, ByVal vertx() As Decimal, ByVal verty() As Decimal, ByVal testx As Decimal, ByVal testy As Decimal) As Int16
    
      ' RETURNS:
      ' -1 IF THE POINT IS OUTSIDE OF THE POLYGON,        
      '  0 IF THE POINT IS ON AN EDGE OR AT A VERTEX,     
      '  1 IF THE POINT IS INSIDE OF THE POLYGON
    
        Dim i As Int16 = 0
        Dim j As Int16 = 0
        Dim c As Int16 = 0
    
        i = 0
        j = nvert - 1
        Do
            If Not ((verty(i) > testy) = (verty(j) > testy)) Then
                If testx < (vertx(j) - vertx(i)) \* (testy - verty(i)) / (verty(j) - verty(i)) + vertx(i) Then
                    c = Not c
                End If
            End If
            j = i
            i = i + 1
        Loop Until Not i < nvert
        pnpoly = c
    End Function
    

    I have converted it based on notes in the source article, specifically: in the C language, when executing the code a&&b, if a is false, then b must not be evaluated. If your compiler doesn't do this, then it's not implementing C, and you will get a divide-by-zero and Explanation of "for (i = 0, j = nvert-1; i < nvert; j = i++):" The intention is to execute the loop for each i from 0 to nvert-1. For each iteration, j is i-1. However that wraps, so if i=0 then j=nvert-1. Therefore the current edge runs between verts j and i, and the loop is done once per edge. In det

    C / C++ / MFC html

  • Issues with sorting a dynamically created Gridview
    A AaronM_NZ

    Thank you, that has worked! (dt.Columns.Add("_SortColumn_").DataType = System.Type.GetType("System.Decimal"))

    ASP.NET database algorithms help question

  • Issues with sorting a dynamically created Gridview
    A AaronM_NZ

    I am working on a project and I am a bit stumped with sorting of a Gridview. I am creating a DataTable, and one of the columns is populated with decimal numbers ranging from -100.00 to +100.00. I then DataBind the DataTable to the GridView, and then sort on the column. The problem is its sorting it as text, not as decimal numbers - so its sorted something like this: 9.33, -7.6, 3.3, 2.02, 14.6, -1.8, -1, 0.99, etc which isn't at all what I want! How can I make the GridView realise the data is decimal, not text, and sort correctly. I am almost at the point where I might just insert the numbers back into SQL as decimal, and then read it back in sorted! Thanks

    ASP.NET database algorithms help question

  • Microsoft 2008 Launch Event
    A AaronM_NZ

    Not at the NZ one, just a 90 day trial: :( The Launch Wave 2008 promotional pack includes: 1 x Windows Server 2008 Enterprise Edition with 1 virtualisation license RTM 1 x Visual Studio 2008 Team Suite 90 day trial 1 x SQL CTP 6 (Community Technology Preview) plus a SQL RTM (final version) voucher for SQL Standard 1 user Attendees will also recieve: A 40% discount voucher on a TechNET Plus Single User subscription 1 x Service Pack 1 for Windows Vista DVD Extracted from http://www.microsoft.com/nz/events/launchwave/default.mspx[^]

    The Lounge question
  • Login

  • Don't have an account? Register

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