Sunday, August 2, 2009

How to open favorites files in visual basic ?

hi


did any one know how to open *.url* file(favorites file) in the webbrowser tool in visual basic ?





thanks

How to open favorites files in visual basic ?
1. Start a new Standard.Exe project.


2. With the Form outline on the screen.. from the VB Menu.. click on Tools - %26gt; Menu Editor and add a menu structure like so.





Key "Caption"





mnuFavorites "Favorites"


mnuAdd "Add"


mnuDelete "Delete"


mnuDltNone "NO Delete"


mnuDlt(0) "Dlt(0)" %26lt;-- Set Visible = False


mnuURL(0) "URL(0)" %26lt;-- Set Visible = False





3. Copy and Paste the code below into the Form code window.


4. Press F5 to run. Click on the Menu Bar or mouse click on the form for the Menu to show.





%26lt;---- Code Begin -----%26gt;





Option Explicit





Private m_intMenuFavorites As Integer





Private Sub Form_Click()





PopupMenu mnuFavorites





End Sub





Private Sub Form_Load()





m_intMenuFavorites = 5


Call xMenuAdd("A", "A")


Call xMenuAdd("B", "B")


Call xMenuAdd("C", "C")


Call xMenuAdd("D", "D")


Call xMenuAdd("E", "E")


Call xMenuAdd("F", "F")





End Sub





Private Sub mnuDlt_Click(Index As Integer)





Dim intIndex As Integer


intIndex = MsgBox("Are You Sure You Want To Delete This Favorite?" _


%26amp; vbCrLf %26amp; vbCrLf _


%26amp; mnuDlt(Index).Caption, _


vbOKCancel, _


"Favorite Place Delete")


If intIndex = vbCancel _


Then


Exit Sub


End If





For intIndex = Index To mnuUrl.UBound - 1


mnuDlt(intIndex).Visible = mnuDlt(intIndex + 1).Visible


mnuDlt(intIndex).Caption = mnuDlt(intIndex + 1).Caption


mnuDlt(intIndex).Tag = mnuDlt(intIndex + 1).Tag


mnuUrl(intIndex).Visible = mnuUrl(intIndex + 1).Visible


mnuUrl(intIndex).Caption = mnuUrl(intIndex + 1).Caption


mnuUrl(intIndex).Tag = mnuUrl(intIndex + 1).Tag


Next intIndex


mnuDlt(mnuDlt.UBound).Visible = False


mnuUrl(mnuUrl.UBound).Visible = False





End Sub





Private Sub xMenuAdd(ByVal strCaption As String, ByVal strTag As String)





If mnuUrl(0).Visible = True _


Then


If mnuUrl.Count %26lt; m_intMenuFavorites _


Then


Load mnuUrl(mnuUrl.Count)


Load mnuDlt(mnuDlt.Count)


End If


Dim intIndex As Integer


For intIndex = mnuUrl.UBound - 1 To 0 Step -1


mnuDlt(intIndex + 1).Visible = mnuUrl(intIndex).Visible


mnuDlt(intIndex + 1).Caption = mnuUrl(intIndex).Caption


mnuDlt(intIndex + 1).Tag = mnuUrl(intIndex).Tag


mnuUrl(intIndex + 1).Visible = mnuUrl(intIndex).Visible


mnuUrl(intIndex + 1).Caption = mnuUrl(intIndex).Caption


mnuUrl(intIndex + 1).Tag = mnuUrl(intIndex).Tag


Next intIndex


End If





mnuDlt(0).Visible = True


mnuDlt(0).Caption = strCaption


mnuDlt(0).Tag = strTag


mnuUrl(0).Visible = True


mnuUrl(0).Caption = strCaption


mnuUrl(0).Tag = strTag





End Sub





%26lt;----- Code End -----%26gt;


No comments:

Post a Comment