Tuesday, 28 July 2015

adodb.connection USER-defined type not defined

In the VBE select Tools -> References... From the dialog box that pops up, and find something like

Microsfot ActiveX Data Objects 2.7 Library or higher number. Select this and then compile



Monday, 27 July 2015

Difference between Single & First in LINQ

Single:
DBContext db = new DBContext();
Customer customer = db.Customers.Where( c=> c.ID == 5 ).Single();
The single  throws exception if multiple records are returned.

The First method provides the first record returned by the query.

First
BContext db = new DBContext();
NewsItem newsitem = db.NewsItems.OrderByDescending( n => n.AddedDate ).First();

Send email in lotus notes via macro

Set a reference to "Lotus Notes Automation Classes". In the code window, go to Tool --> References --> Select 'Lotus Notes Automation Classes".

Sub Send_Email_via_Lotus_Notes()
    Dim Maildb As Object
    Dim MailDoc As Object
    Dim Body As Object
    Dim Session As Object
    'Start a session of Lotus Notes
        Set Session = CreateObject("Lotus.NotesSession")
    'This line prompts for password of current ID noted in Notes.INI
        Call Session.Initialize
    'or use below to provide password of the current ID (to avoid Password prompt)
        'Call Session.Initialize("<password>")
    'Open the Mail Database of your Lotus Notes
        Set Maildb = Session.GETDATABASE("", "D:\Notes\data\Mail\eXceLiTems.nsf")
        If Not Maildb.IsOpen = True Then Call Maildb.Open
    'Create the Mail Document
        Set MailDoc = Maildb.CREATEDOCUMENT
        Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
    'Set the Recipient of the mail
        Call MailDoc.REPLACEITEMVALUE("SendTo", "Ashish Jain")
    'Set subject of the mail
        Call MailDoc.REPLACEITEMVALUE("Subject", "Subject Text")
    'Create and set the Body content of the mail
        Set Body = MailDoc.CREATERICHTEXTITEM("Body")
        Call Body.APPENDTEXT("Body text here")
    'Example to create an attachment (optional)
        Call Body.ADDNEWLINE(2)
        Call Body.EMBEDOBJECT(1454, "", "C:\dummy.txt", "Attachment")
    'Example to save the message (optional) in Sent items
        MailDoc.SAVEMESSAGEONSEND = True
    'Send the document
    'Gets the mail to appear in the Sent items folder
        Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
        Call MailDoc.SEND(False)
    'Clean Up the Object variables - Recover memory
        Set Maildb = Nothing
        Set MailDoc = Nothing
        Set Body = Nothing
        Set Session = Nothing
End Sub



This is as described by article in  http://www.excelitems.com

Tuesday, 21 July 2015

Search From right side in Excel VBA

Use the  function InStrRev(String searched, String Sought, Start, CompareMethod)

InstrRev(one_two_three,"_") should return 8, so the search is from the right, But the position is returned from the left.







Monday, 20 July 2015

Naming Convention in c#

Pascal Naming Convention
Capitalizes the first character of each word (including acronyms over two letters in length), as shown in the following examples:



PropertyDescriptor
HtmlTag
A special case is made for two-letter acronyms in which both letters are capitalized, as shown in the following identifier:
IOStream
This naming convention is used for 
1) Class Names
2) Method Names
3) File Names


Camel Naming Convention
The camelCasing convention, used only for method parameter names and variables.

capitalizes the first character of each word except the first word, as shown in the following examples. As the example also shows, two-letter acronyms that begin a camel-cased identifier are both lowercase.
propertyDescriptor
ioStream
htmlTag

Expand all columns of cell

Select the top left corner cell between 1 and A. This will select the entire sheet.

Now go and try to expand all the  columns, This should expand all the columns.


Sunday, 19 July 2015

Running macros using hyperlink



VBA programmers deals with macros now and then, and to run the marco by clicking hyperlink should catch the event of clicking of the hyperlink.

The event which does this is
Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
 
As this belongs to the WorkSheet, it should go into the Worksheet 

1. Right click and hyperlink the text you want to hyperlink.

2. Select the developer tab and open up visual basic, or you can do Alt + F11
 3. In the folder “Microsoft Excel Objects” there is a list of the sheets contained within the workbook. Select the sheet that contains the hyperlink.
4. Paste the following code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    'Write your code here
    

End Sub

Friday, 10 July 2015

Screen Shot using Windows Phone O.S. 8.1

Hold your power button, the single button at the bottom on the right side, and simultaneously click the "Volume up"  button on the right side. See your screen shot in the "Photos App"

stop app or whatsapp notification in windows mobile 8.1


  1. Swipt the top down, go to "ALL Settings"
  2. Go to "Notifications+actions"
  3. Find the app you want to change the way notifications work
  4. Just change the "Notification sound" to "none".
See the image of "Notifications and Actions"