[VB6] Read Excel Files


Deskripsi
     To read data cell in Excel files.

Howto
   Dim oexcel As Object
   Dim obook As Object
   Dim osheet As Object
   Dim var As Variant

   Set oexcel = CreateObject("Excel.Application")
   Set obook = oexcel.workbooks.Open("D:\Developer\sample.xlsx")
   Set osheet = obook.worksheets(1)

   ' you can read with two method, just uncomment below
   ' var = osheet.Range("A1").Value
   'or
   'var = osheet.Cells(1, 1).Value 'Row , Column

   MsgBox var
   Set osheet = Nothing
   obook.Close
   oexcel.Quit

[VB.NET] Parsing JSON using Newtonsoft Library


Deskripsi
       To get some value in json format for VB.NET

Howto
1. Download Newtonsoft library here
2. Add reference at Project > Add Reference and Imports Newtonsoft.Json in your code
3. Copy paste code below :
   'create sample json string
   Dim jsontext As String = "{""name"":""mahendra"",""language"":""vb.net"",""settings"":{""framework"":""3.5""}}"
 
   'read the jsontext
    Dim readingJson = Newtonsoft.Json.Linq.JObject.Parse(jsontext)
    MessageBox.Show(readingJson.Item("settings")("framework").ToString)

   'it will return value : "3.5"
   it's not working if the type json array (json which have some bracket like this '[' or ']') 

But , if you want deserialize JSON without using this library , you can use .NET library (.NET 4.0 FULL not CLIENT PROFILE)

#Start Here
Imports System.Web.Script.Serialization

Dim js As New System.Web.Script.Serialization.JavaScriptSerializer
Dim data = js.Deserialize(Of Dictionary(Of Object, Object))(json)
Dim dataDeserial = data.Values

msgbox("Count : " & dataDeserial(X)(X)(X........).Length)

For i = 0 To dataDeserial(X)(X)(X........).Length - 1
       ' do something
Next i

'Note : (X)(X)(X........) ==> based on how deep your JSON

[VB.NET] Twitter Library


Deskripsi
    This is my first library that can connect API twitter, very simple but not accomodate all API.
Release Date :
11-10-2013 *ver: 1.0.0.0

Api Support (Api Version : 1.1):
- For data retrieval
GET statuses/mentions_timeline *tested
GET statuses/user_timeline *tested
GET statuses/home_timeline *tested
GET statuses/retweets_of_me  *not tested

- For posting tweets
POST statuses/update *tested

Required : .NET Framework 4
Download Here : TwitterLib

*Note : - if success it will return JSON (for data retrieval), tweet posting not return JSON
             - Data retrieval limited 15 request / 15 minutes (it's policy from twitter, if you flood the request your account will be blacklist permanently so use wisely !!)

Howto
1. before use this library make sure you already have account twitter and login at dev.twitter.com
2. create new application (to open just click your avatar and select new application)
3. after you create application you get 4 key :
     - consumer key
     - consumer secret
     - access token  *status readonly
     - access token secret *status readonly
4. if you want to posting tweets , you must setting access token to "read , write" you can change by click SETTINGS (in you application that you create) select application type , after that click update setting and back  to menu DETAILS click Recreate my access token then you will get new access token and access token secret.
5. save this 4 key in notepad , we will use this in my library.

this library i test in VB.NET , i don't sure if use in VB6 or another programming language.

Add refference Library : - Project > Add Refference
                                      - Import in your project : Imports TwitterLib

Here's the syntax :
------------------------------------------------------------------------------------------------------------
* For posting tweets
        Dim json As String
        Dim objtwitter As New TwitterLib.TwitterLib
        objtwitter.chooseWorkType = 1 ' 0 for retrieval , 1 for updatestatus
        objtwitter.chooseMethod = 1 ' 0 for get(data retrieval) , 1 for post(Post tweets) ' see REST API 1.1 !
        objtwitter.updateStatus = "My First Tweets using Api"
        objtwitter.oauth_consumer_key = "XXX"
        objtwitter.oauth_consumer_secret = "YYY"
        objtwitter.oauth_token = "ZZZZ"
        objtwitter.oauth_token_secret = "AAAA"
        objtwitter.oauth_resource_url = "https://api.twitter.com/1.1/statuses/update.json" 'see my description
        json = objtwitter.Connect_Api_Twitter()
        System.Diagnostics.Debug.Write(json) 'normally posting doesnt return json


-----------------------------------------------------------------------------------------------------------
* For Data Retrieval
        Dim json As String
        Dim objtwitter As New TwitterLib.TwitterLib
        objtwitter.chooseMethod = 0 ' 0 for get , 1 for post
        objtwitter.chooseWorkType = 0 ' 0 for retrieval , 1 for updatestatus
        objtwitter.count = 10
        objtwitter.oauth_consumer_key = "xxxx"
        objtwitter.oauth_consumer_secret = "yyyy
        objtwitter.oauth_token = "aaaa"
        objtwitter.oauth_token_secret = "zzzzz"
        objtwitter.oauth_resource_url = "https://api.twitter.com/1.1/statuses/user_timeline.json" 'see my description
        json = objtwitter.Connect_Api_Twitter()
        messagebox.show(json)
        MessageBox.Show("limitation Request: " & objtwitter.limitation)
        MessageBox.Show("limitation Use : " & objtwitter.rate_limit)

after get JSON , you must still parser manually.

if error occured / bug / question , please comment in bottom ....  thank you :D

[Hyperion] Essbase got corruption

Deskripsi
      How to recover Essbase from corruption .

Howto
     go to this web :
     http://www.in2hyperion.com/websites/in2hyperionblog/post/2011/01/31/Recovering-An-Essbase-Application-From-a-Corrupt-Data-File.aspx

already test and it work's great :D

[VB.NET] Web Header (Request and Response)


Deskripsi
    i don't know if my article is still working , here's the code of web header for request or response for vb.net

Howto
 
   Get current your web header (request) and send to webserver :

        Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.msn.com"), HttpWebRequest)
        Dim myWebHeaderCollection As WebHeaderCollection = myHttpWebRequest.Headers

        myWebHeaderCollection.Add("Accept-Language:da")
        myWebHeaderCollection.Add("Accept-Language", "en;q" + ChrW(61) + "0.8")
        myHttpWebRequest.Method = "POST"
        myHttpWebRequest.ContentType = "application/x-www-form-urlencoded"

        'Get the associated response for the above request.
        Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)

        'Print the headers for the request.
        System.Diagnostics.Debug.Write(myWebHeaderCollection)
        myHttpWebResponse.Close()


      Get current response web header from webserver :
Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create("http://www.detik.com"), HttpWebRequest)
        ' Sends the HttpWebRequest and waits for a response.
        Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)
        System.Diagnostics.Debug.Write(ControlChars.Lf + ControlChars.Cr + "The following headers were received in the response")
        Dim i As Integer
        While i < myHttpWebResponse.Headers.Count
            System.Diagnostics.Debug.Write(myHttpWebResponse.Headers.Keys(i) & ":" & myHttpWebResponse.Headers(i) & vbCrLf)
            i = i + 1
        End While
        myHttpWebResponse.Close()