• 0

[vb.net] Opening files in notepad


Question

5 answers to this question

Recommended Posts

  • 0
  Menge said:
i believe it'd be more correct to do

shell("notepad.exe filename")

since the windows dir in in the PATH environment variable and the win install dir may vary :)

585495784[/snapback]

I agree, try not to hardcode, avoid it at most times.

  • 0

another option is the ShellExecute function. This executes the associated program. (ie Notepad, IE, Netscape) Whatever is the default association with the extention you are working with.

Be aware, it will not SPECIFICALLY open NOTEPAD, but whatever application the user has associated with the file type. This can be good or bad depending on your needs.

Example

'Constant for Shell Exec

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Global Const SW_SHOWNORMAL = 1

Dim sValue As String

Dim lRet As Long

sValue = "c:\temp\information.txt"

lRet = ShellExecute(Me.hwnd, vbNullString, sValue, vbNullString, Left$(sValue, 3), SW_SHOWNORMAL)

Edited by jameswjrose
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • And of course that battery is the thing I'll need to replace sooner or later. It's starting to act a little flaky in its charge meter and that glue is just annoying to deal with. No need for it to be glued in place.
    • I'll say you are 50% correct. On the content side, yes, YouTube's content is basically free. Some might point out that they share ad revenue with creators, but I'll side with you saying that doesn't count. If the ad isn't viewed, the creator gets nothing from YouTube, so viewing the content is net-zero for everyone, not net-negative. The other half of the equation is the platform costs. Both YouTube and Netflix have a cost to provide their service. Netflix bakes the cost into their plans, which can be plainly seen by the different resolutions offered at different tiers, which is a pure platform cost. As you pointed out, YouTube doesn't pay licensing fees, so their entire cost structure is the platform. Using that platform without watching the ads (or paying for premium) is not net-zero like above, in this case it is net-negative. You consumed resources on YouTube systems that YouTube very clearly is not offering for free, they expect compensation in the form of viewing ads or paying for premium. TLDR, the company offering the service sets the price, either in currency or ad viewing. As the consumer, you can choose to make that agreement or not. Consuming the service without paying the price is not being offered.
    • Exactly that, in my case it doesn't work at all!
    • Last chance to download The Cybersecurity Control Playbook (worth $100) for free by Steven Parker Claim your complimentary eBook worth $100 for free, before the offer ends on June 4. Implement effective cybersecurity measures for all organizations Cybersecurity is one of the central concerns of our digital age. In an increasingly connected world, protecting sensitive data, maintaining system integrity, and ensuring privacy have never been more important. The Cybersecurity Control Playbook offers a step-by-step guide for implementing cybersecurity controls that will protect businesses and prepare them to compete in an overwhelmingly networked landscape. With balanced coverage of both foundational and advanced topics, and concrete examples throughout, this is a must-own resource for professionals looking to keep their businesses safe and secure. Readers will also find: Clear, jargon-free language that makes it accessible to a wide range of readers An introduction to developing, deploying, monitoring, testing, and retiring controls and control frameworks across large, medium, and small enterprises A system for identifying, prioritizing, and managing cyber risks based on the MITRE ATT&CK framework, with additional coverage of other key cybersecurity frameworks The Cybersecurity Control Playbook is ideal for cybersecurity practitioners, IT professionals, and security managers who are responsible for implementing and managing cybersecurity strategies in their organizations. How to get it Please ensure you read the terms and conditions to claim this offer. Complete and verifiable information is required in order to receive this free offer. If you have previously made use of these free offers, you will not need to re-register. While supplies last! Download The Cybersecurity Control Playbook (worth $100) for free Offered by Wiley, view other free resources The below offers are also available for free in exchange for your (work) email: The Cybersecurity Control Playbook ($100 Value) FREE – Expires today 6/4 The Embedded Linux Security Handbook ($31.99 Value) FREE – Expires today 6/4 Teach Yourself VISUALLY Microsoft 365, 2nd Edition ($20 Value) FREE – Expires 6/4 Winxvideo AI V3.0 Lifetime License for PC ($69.95 Valued) FREE – Expires 6/8 Aiarty Image Enhancer for PC/Mac ($85 Value) FREE – Expires 6/8 Solutions Architect's Handbook, Third Edition ($42.99 Value) FREE – Expires 6/10 AI and Innovation ($21 Value) FREE – Expires 6/11 Macxvideo AI ($39.95 Value) Free for a Limited Time – Expires 6/22 The Ultimate Linux Newbie Guide – Featured Free content Python Notes for Professionals – Featured Free content Learn Linux in 5 Days – Featured Free content Quick Reference Guide for Cybersecurity – Featured Free content We post these because we earn commission on each lead so as not to rely solely on advertising, which many of our readers block. It all helps toward paying staff reporters, servers and hosting costs. Other ways to support Neowin The above deal not doing it for you, but still want to help? Check out the links below. Check out our partner software in the Neowin Store Buy a T-shirt at Neowin's Threadsquad Subscribe to Neowin - for $14 a year, or $28 a year for an ad-free experience Disclosure: An account at Neowin Deals is required to participate in any deals powered by our affiliate, StackCommerce. For a full description of StackCommerce's privacy guidelines, go here. Neowin benefits from shared revenue of each sale made through the branded deals site.
    • I use Firefox for all the reasons already mentioned above and I also use Edge mainly because I like the snappiness of it. It does seem snappier then Firefox to me. I figure I might as well have 1 of each type browser engine. I probably won't use Edge as much once they follow in Googles footsteps of killing my ad blocker. I play around with several other browsers usually when I see an updated story on them here just to see if they can persuade me to stick with them, but they usually don't. Have never figured out what it is about Google Chrome that makes others like it so much? Heck, it isn't even smart enough to give you an option to alphabetize your bookmarks!
  • Recent Achievements

    • Week One Done
      mywakehealth earned a badge
      Week One Done
    • Dedicated
      jbatch earned a badge
      Dedicated
    • Week One Done
      Leonard grant earned a badge
      Week One Done
    • One Month Later
      portacnb1 earned a badge
      One Month Later
    • Week One Done
      portacnb1 earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      295
    2. 2
      snowy owl
      162
    3. 3
      +FloatingFatMan
      156
    4. 4
      ATLien_0
      143
    5. 5
      Xenon
      125
  • Tell a friend

    Love Neowin? Tell a friend!