Results 1 to 5 of 5

Thread: Webbrowser control - how to display only ONE specific html file

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    59

    Webbrowser control - how to display only ONE specific html file

    Hello,

    I am using a web browser control on a VB form to display html files from a mapped drive on the network. I am not sure if this is the best way to do what i want, but the code was already there so I have just started using it. I want to display say e.g., there is an html file About 123.html and I want to display this file, I use the Navigate method with complete path and name of the file. Now, the problem is the web browser control first goes to the Default.htm file in the same folder (which is the intranet folder) and displays the whole intranet in the web browser and then goes to the file in question.
    All I want is to be able to display the About 123.html and that's it. How can I do this??

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Webbrowser control - how to display only ONE specific html file

    Moved to Classic VB Forum.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Webbrowser control - how to display only ONE specific html file

    Could you post your code?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2002
    Posts
    59

    Re: Webbrowser control - how to display only ONE specific html file

    Sure, here is the code. However, I just noticed that it seems to be working sometimes and other times not. So, I m not too worried about it now. Although, I would like to know if there is anything I m doing wrong.

    VB Code:
    1. strAboutFile = Dir(CONST_DIR & "\About " & Me.lstFileName.List(lstFileName.ListIndex) & ".htm")
    2.     If strAboutFile = "" Then
    3.         strAboutFile = Dir(CONST_DIR & "\NoHelpFile.htm")
    4.         Me.lstHelpFiles.AddItem "TemplateList", 0
    5.         Me.lstHelpFiles.AddItem "NoHelpFile", 1
    6.     Else
    7.         Me.lstHelpFiles.AddItem "TemplateList", 0
    8.         Me.lstHelpFiles.AddItem "About " & Me.lstFileName.List(lstFileName.ListIndex), 1
    9.     End If
    10.     'Me.lstHelpFiles.AddItem strAboutFile
    11.     Me.WebBrowser.Navigate2 CONST_DIR & strAboutFile
    • strAboutFile holds the name of the html file to be displayed
    • lstHelpFiles is a list box of documents to choose from - html file relates to the selection made
    • CONST_DIR contains the absolute path of the html file


    Thanks,

  5. #5
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Webbrowser control - how to display only ONE specific html file

    This doesn't seem to be a problem with the WebBrowser control. Your strAboutFile variable doesn't seem to hold the correct value. Just put a breakpoint on the last line and check the value of CONST_DIR & strAboutFile.

    Moreover I think the correct line should be:
    VB Code:
    1. Me.WebBrowser.Navigate2 CONST_DIR & "\" & strAboutFile
    Last edited by Pradeep1210; Jun 21st, 2005 at 05:05 AM.
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width