• 0

Show text readme with choice from listbox


Question

Im self educated on visual basic programming. so its basically a learning curve.

 

but need help with something.

 

 

using visual studio 2013 with visual basic net

 

working on map loader for a pc game.

 

there is a txt file with credits and info in the same directory as the maps.

 

so far I have a listbox that scans the directory and shows all the map files and then user selects the map and then clicks a start button and it loads the game with the map. 

 

but I also want to a have a txt box for the map selected showing the information for the map.

 

so what I want to do is when a user clicks on a map in the listbox,it will show a preview of the maps txt file in a separate box on the form.

6 answers to this question

Recommended Posts

  • 0

If your description files have the same name as the maps other than the extension you could just use System.IO.Path.ChangeExtension to create the file name of the text object then load it with File.ReadAllText

 

    Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
        If ListBox1.SelectedItem IsNot Nothing And TypeOf ListBox1.SelectedItem Is String Then
            Dim selectedMap As Object = ListBox1.SelectedItem
            Dim mapDescriptionFile As String = Path.ChangeExtension(selectedMap, "txt")
            If File.Exists(mapDescriptionFile) Then
                TextBox1.Text = File.ReadAllText(mapDescriptionFile)
            End If
        End If
    End Sub
If they're not the same you can either build a dictionary with the map filename as the key and description filename as the value. Or if you want to be lazy you can use a ListView instead and set the Tag property to the description filename. :)

 

    Private Sub ListView1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListView1.SelectedIndexChanged
        If ListView1.SelectedItems IsNot Nothing And TypeOf ListView1.SelectedItems(0).Tag Is String Then
            Dim selectedMap As ListViewItem = ListView1.SelectedItems(0)
            Dim mapDescriptionFile As String = selectedMap.Tag

            If File.Exists(mapDescriptionFile) Then
                TextBox1.Text = File.ReadAllText(mapDescriptionFile)
            End If
        End If
    End Sub
(The second example assumes that you have set the ListView's MultiSelect property to False since you would only want to display the description for one map at a time.)
  • 0
  On 30/07/2014 at 03:28, dsbig said:

Im self educated on visual basic programming. so its basically a learning curve.

 

but need help with something.

 

 

using visual studio 2013 with visual basic net

 

working on map loader for a pc game.

 

there is a txt file with credits and info in the same directory as the maps.

 

so far I have a listbox that scans the directory and shows all the map files and then user selects the map and then clicks a start button and it loads the game with the map. 

 

but I also want to a have a txt box for the map selected showing the information for the map.

 

so what I want to do is when a user clicks on a map in the listbox,it will show a preview of the maps txt file in a separate box on the form.

 

Hi,

 

I am trying to help you as much as I can but from the looks of your program you want to show a preview of the map, correct? Are you trying to show a Picture of your map or anything else?

 

Normally, you would use the Drawing class to display images on a container or a datagrid. Quickest way would be to add a .NET label on your application, and when the user selects a map you fire an event to load a .bmp file from a specific location.

 

Private Sub CreateMyLabel()

    ' Create a new label and bitmap. 

    Dim Label1 As New Label()
    Dim Image1 As Image

    Image1 = Image.FromFile("c:\\MyImage.bmp")


    ' Set the size of the label to accommodate the bitmap size.

    Label1.Size = Image1.Size        

    ' Initialize the label control's Image property.

    Label1.Image = Image1

    ' ...Code to add the control to the form... 

End Sub
  • 0

I have a listbox  that scans a folder for *.map files and shows a list of maps in the listbox.

 

and there is also a txt file that has credit and also information that folder.

 

when clicking a map title in the listbox. a textbox will show the information for that map.

 

 

list of maps

 

listbox_zps008f2eea.png

 

when someone select a map then it would show the matching .txt file with the information in a box like this. 

 

mapread_zps14dfd2b8.png

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

    • No registered users viewing this page.
  • Posts

    • Mozilla shuts down even more Firefox services you might still be using by David Uzondu A few weeks ago, Mozilla announced that its Pocket and Fakespot services were getting the axe as the company focuses more on Firefox. It is a complete shutdown. Pocket, the read-it-later service Mozilla bought in 2017, will stop working on July 8, 2025. You have until October 8 to get your saved articles out before they are deleted forever. Fakespot, which helped you spot garbage product reviews, is also being sunsetted. But the house cleaning does not stop with those two. Neowin has spotted a shutdown notice dated June 26, 2025 for Deep Fake Detector, the Firefox extension that was supposed to tell you if a piece of text was written by a human or an AI chatbot. That tool used a combination of Mozilla's own proprietary ApolloDFT engine and open-source models like ZipPy to give you a verdict on what you were reading. The notice says: This brings us to the AI tools. Following the pattern, the Orbit website was updated with a banner that announced the service would shut down by June 26. Orbit was Mozilla's big privacy-first experiment in AI. It was a Firefox add-on that could summarize articles and answer questions about a webpage's content without sending your data to a third party. This is not an AI exit. Mozilla is simply changing how it delivers AI features. Orbit's private, self-contained setup can be replaced with the new sidebar built directly into Firefox, letting you connect to third-party chatbots like ChatGPT and Gemini. But, for Orbit users, this is still a huge loss, as a key feature of the service was privacy. Your prompts were handled by Mistral LLM (Mistral 7B) within Mozilla's GCP instance and were not shared with other companies for model training, which was a huge selling point for people tired of being the product. Mozilla keeps saying these cuts are necessary. As the only major browser not owned by a tech giant, its resources are limited; hence, the need to focus its cash and engineering talent on the core Firefox browser to compete.
    • Too close to the Ultra, I have and love an Ultra but have held onto my watch 6 classic because it is nicer when wearing a suit to work.
    • Intel v32.0.101.6881 graphics driver fixes a popular multiplayer hero shooter by Taras Buria Intel is rolling out a new graphics driver under version 32.0.101.6881. This WHQL release does not contain much. In fact, there is only a single fix for a popular multiplayer hero shooter. The new driver fixes crashes when launching Overwatch 2 (DirectX 12) on High or Ultra graphics settings on Intel Arc A-Series graphics cards. From the changelog: Overwatch 2 (DX12) may experience an application crash while launching the game with High or Ultra graphics quality settings. Known bugs in the drive include the following: Intel Arc B-Series Graphics Products: Fortnite may experience an application crash when “Performance - Lower Graphical Fidelity” is selected as Rendering Mode. Recommendation is to use default Rendering Mode – DX12. Visual corruptions may appear in certain scenarios with multiple application interactions. Call of Duty: Black Ops 6 (DX12) may exhibit flickering corruption in certain scenes during gameplay. Returnal (DX12) may experience an application crash during gameplay with Ray-Tracing settings turned on. Call of Duty: Warzone 2.0 (DX12) may exhibit corruptions on water areas in certain scenarios. SPECapc for Maya 2024 may experience intermittent application freeze during benchmark. PugetBench for Davinci Resolve Studio V19 may experience an application crash while running the benchmark. HWiNFO may incorrectly report number of Xe Cores for certain Intel Arc B-Series Graphics Products. Intel Arc A-Series Graphics Products: Returnal (DX12) may experience an application crash during gameplay with Ray-Tracing settings turned on. Marvel’s Spider-Man 2 (DX12) may experience an application crash with Ray-Tracing and XeSS enabled. PugetBench for Davinci Resolve Studio V19 may experience an application crash while running the benchmark. Intel Core Ultra Series 1 with built-in Intel Arc GPUs: Adobe Premiere Pro may fail to import video. Mitigation is to use Intel NPU Driver version 32.0.100.3717 or lower. PugetBench for Davinci Resolve Studio V19 may experience errors intermittently with benchmark preset set to Extended. Intel Core Ultra Series 2 with built-in Intel Arc GPUs: Valorant (DX11) may fail to enumerate supported resolutions in game settings. Adobe Premiere Pro may experience an intermittent application crash. Adobe Premiere Pro may fail to import video. Mitigation is to use Intel® NPU Driver version 32.0.100.3717 or lower. PugetBench for Davinci Resolve Studio V19 may experience errors intermittently with benchmark preset set to Extended. You can install Intel 32.0.101.6881 WHQL driver on PCs with 64-bit Windows 10 and Windows 11 with the following graphics products from Intel: Discrete GPUs Integrated GPUs Intel Arc A-Series (Alchemist) Intel Arc B-Series (Battlemage) Intel Iris Xe Discrete Graphics (DG1) Intel Core Ultra Series 2 (Lunar Lake and Arrow Lake) Intel Core Ultra (Meteor Lake) Intel Core 14th Gen (Raptor Lake Refresh) Intel Core 13th Gen (Raptor Lake) Intel Core 12th Gen (Alder Lake) Intel Core 11th Gen (Tiger Lake) You can download the driver from the official website here. Full release notes are available here (PDF).
    • Just look at the shiney shiney Vista clone, ignore the fact that they are a disaster in anything AI related. Roll on the class actions for all iPhone 16 owners.
  • Recent Achievements

    • Collaborator
      Carltonbar earned a badge
      Collaborator
    • Explorer
      MusicLover2112 went up a rank
      Explorer
    • Dedicated
      MadMung0 earned a badge
      Dedicated
    • Rookie
      CHUNWEI went up a rank
      Rookie
    • Enthusiast
      the420kid went up a rank
      Enthusiast
  • Popular Contributors

    1. 1
      +primortal
      501
    2. 2
      ATLien_0
      269
    3. 3
      +FloatingFatMan
      249
    4. 4
      +Edouard
      200
    5. 5
      snowy owl
      168
  • Tell a friend

    Love Neowin? Tell a friend!