Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 16065

VS 2017 Toggle between two images based on filename

$
0
0
Hi ... I am trying to toggle an image in a single image box. I am loading an image file using 'open file dialogue'. Once that image is loaded, I want to be able to toggle to the filename that matches the end charatcers criteria. For example: Load "Image1_TOP", now I want to have a toggle to allow loading "Image1_BTM". The filenames will all have a match with either _TOP or _BTM on the end. This is what I am using, but I am sending myself in circles. I can get the opposite image to load, but I can't get back to the original loaded to get that toggle action. I'm sure there must be a simpler way to do this, but I figured I have to be starting with the longest route possible. Thanks for your help and time!

Code:

Dim sInput As String = myShrtFileName
        Dim CCASide As String
        CCASide = sInput.Substring(sInput.Length - 3)

        If CheckBox1.CheckState = CheckState.Checked And CCASide = "TOP" Then
            Dim str As String = myShrtFileName
            myShrtFileName = (str.Substring(0, str.Length - 3))
            Me.PictureBox1.Image = Nothing
            PictureBox1.Image = Image.FromFile(prgPath & "\CCA_Images\" & myShrtFileName & "BTM.bmp")
            CCASide = "BTM"
        ElseIf CheckBox1.CheckState = CheckState.Checked And CCASide = "BTM" Then
            Dim str As String = myShrtFileName
            myShrtFileName = (str.Substring(0, str.Length - 3))
            Me.PictureBox1.Image = Nothing
            PictureBox1.Image = Image.FromFile(prgPath & "\CCA_Images\" & myShrtFileName & "TOP.bmp")
            CCASide = "TOP"
        End If

        If CheckBox1.CheckState = CheckState.Unchecked Then
            Me.PictureBox1.Image = Nothing
            PictureBox1.Image = Image.FromFile(prgPath & "\CCA_Images\" & myShrtFileName & "TOP.bmp")
        ElseIf CheckBox1.CheckState = CheckState.Unchecked Then
            Me.PictureBox1.Image = Nothing
            PictureBox1.Image = Image.FromFile(prgPath & "\CCA_Images\" & myShrtFileName & "BTM.bmp")
        End If


Viewing all articles
Browse latest Browse all 16065

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>