Translate

10.2.18

Strange Thoughts - CSpydo

Sometimes I feel like I'm not as good as the best of coders. And then I go ahead and pull some crazy code stunts (most times, php/ C#, cos I just looooove em). And then I feel like I'm actually really good at thinking crazy ways out of tight corners.

And then I get a phone call about the possibility of joining a pretty cool project as developer. And then I start feeling Awesome again.

And then I realise, I should start my own firm. Wait, I already have a firm. Okay, I should seriously start running my firm seriously for real. Okay, when I'm done with NYSC.

I should start my own cryptocurrency also, maybe call it SpyCoin or some weird name like that.

Okay, finally decided I'm never abandoning my interest/skills/proficiency/experience in music,writing and performing arts also. I'll make it work somehow.

Okay, seriously need to start working on my To-Meet List also.

One more thing. And I totally got this bad habit from Barney Stinson. ...................Wait for It............


                   I ' M totally A . W . E . S . O . M . E

23.1.18

Yoruba Keyboard

Was with the Tech Club at my current workplace ( a high school in Osogbo, Osun State in Nigeria) trying to argue out the differences between the US and French (AZERTY) keyboard with my students.

Somehow, the idea of a Yoruba keyboard, specifically developed to accomodate yoruba alphabets , symbols and accents came about.

Not Software, I mean Hardware. The kind of keyboard you can just plug in anytime you have a yoruba document to type. That was over 24 hours ago, and its still very active in my head.

But I'm gon need some electronics nuts to roll with me  on this. Lets see how it goes.

And if you happen to be interested in working on it, contact me. 

Lookup Cell Value in MS-Excel VB.Net

Ran into a snag with this stuff in a program I was working on recently. Searched online and found a lot of confusing, not really functional answers. So, built on the ideas and came up with this.

Works perfectly, VB.Net, pretty sure any C# person can translate to C#, and hence, Java, etc.


1. Right Click on your project in Visual Studio.
2. Select Add Reference
3. In the Reference Box, Search for Excel
4. Select Microsoft.Interop.Excel from the Results and Click Ok
5. You Should see Microsoft.Interop.Excel under references in your project. That means you are good to go.

6. Put this at the top of your code  Imports Excell = Microsoft.Office.Interop.Excel

And Here is the method itself:


Public Function OpenExcelData(ByVal FileName As String, ByVal SheetName As String,
                                  ByVal column As Integer, ByVal row As Integer)
        Dim vvalue As Decimal = 0
        Dim dvalue As Object = vbNull
        If IO.File.Exists(FileName) Then
            Dim Proceed As Boolean = False
            Dim xlApp As Excell.Application = Nothing
            Dim xlWorkBooks As Excell.Workbooks = Nothing
            Dim xlWorkBook As Excell.Workbook = Nothing
            Dim xlWorkSheet As Excell.Worksheet = Nothing
            Dim xlWorkSheets As Excell.Sheets = Nothing
            Dim xlCells As Excell.Range = Nothing
            xlApp = New Excell.Application
            xlApp.DisplayAlerts = False
            xlWorkBooks = xlApp.Workbooks

            xlWorkBook = xlWorkBooks.Open(FileName)
            'xlApp.Visible = True
            xlWorkSheets = xlWorkBook.Sheets


            Dim wsno As Integer = 0
            If (sheetparam = 2) Then
                wsno = 1
            ElseIf (sheetparam = 3) Then
                wsno = 2
            End If

            Try
                xlWorkSheet = CType(xlWorkSheets(wsno), Excell.Worksheet)

                Dim xRng As Excell.Range = CType(xlWorkSheet.Cells(row, column), Excell.Range)
                dvalue = xRng.Value()

            Catch os As Exception
                'MessageBox.Show(os.ToString)
            End Try
            vvalue = Decimal.Parse(dvalue)
            xlWorkBook.Close()
            xlApp.UserControl = True
            xlApp.Quit()

            ReleaseComObject(xlCells)
            ReleaseComObject(xlWorkSheets)
            ReleaseComObject(xlWorkSheet)
            ReleaseComObject(xlWorkBook)
            ReleaseComObject(xlWorkBooks)
            ReleaseComObject(xlApp)
        Else
            MessageBox.Show("'" & FileName & "' not located.")
        End If
        Return vvalue
    End Function

    Public Sub ReleaseComObject(ByVal obj As Object)
        Try
            System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
            obj = Nothing
        Catch ex As Exception
            obj = Nothing
        End Try
    End Sub


Modify as necessary. Feel free to give your opinion in comments section.