如果没有图片匹配,则显示msg框 [英] If No Picture match then show msg box

查看:166
本文介绍了如果没有图片匹配,则显示msg框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下面的代码,完全可以感谢你的家伙的帮助,但我有一个代码我不知道该怎么做。对于'得到一个匹配:从VAST文件夹获取图片的样本 - 如果没有匹配,我想显示一个msg框。这是否可能没有关闭我的代码太多?

I have the code below that works perfectly thanks to your guy's help but I have a code Im not sure how to do. For 'got a match: get sample of pic from VAST folder - I would like to show a msg box if no match is found. Is that possible without switching up my code too much?

Private Sub RejectTitleNm_Change()

    Dim f As Range, v

    v = Me.RejectTitleNm.Value

    ' find the selected value in the source range from ColB(RejectTitle)
    Set f = Range("RejectTitle").Find(v, lookat:=xlWhole)

    Me.TextBox1.Text = ""

    If Not f Is Nothing Then
        ' got a match: get value from ColC(Issue) on same row
        Me.TextBox1.Text = f.EntireRow.Cells(, "C").Value
        ' got a match: get value from ColD(TA) on same row
        Me.TextBox2.Text = f.EntireRow.Cells(, "D").Value
        ' got a match: get value from ColE(VBA) on same row
        Me.TextBox3.Text = f.EntireRow.Cells(, "E").Value

        ' REJECT ID
        ' got a match: get value from ColA(RejectID) on same row
        Me.RejectID.Text = f.EntireRow.Cells(, "A").Value

        ' CHANNELS
        ' got a match: get value from ColF(Mail) on same row
        Me.MailChannel.Text = f.EntireRow.Cells(, "F").Value
        ' got a match: get value from ColG(Web) on same row
        Me.WebChannel.Text = f.EntireRow.Cells(, "G").Value
        ' got a match: get value from ColG(Phone) on same row
        Me.PhoneChannel.Text = f.EntireRow.Cells(, "H").Value


        ' got a match: get sample of pic from reject folder
        RejectSamples.Image2.Picture = LoadPicture(ThisWorkbook.Path & "\RejectExamples\" & RejectTitleNm.Value & ".jpg")

        ' got a match: get sample of pic from VAST folder
        Vexamples.VASTEx.Picture = LoadPicture(ThisWorkbook.Path & "\VASTScreens\" & RejectTitleNm.Value & ".jpg")
    End If

End Sub


推荐答案

Private Sub RejectTitleNm_Change()

    Dim f As Range, v

    v = Me.RejectTitleNm.Value                                  ' search value

    Set f = Range("RejectTitle").Find(v, lookat:=xlWhole)       ' search RejectTitle (column B)

    Me.TextBox1.Text = ""

    If Not f Is Nothing Then                                    ' update userForm from data in same row 

        Me.TextBox1.Text = f.EntireRow.Cells(, "C").Value       ' Issue (column C in "found" row)
        Me.TextBox2.Text = f.EntireRow.Cells(, "D").Value       ' TA
        Me.TextBox3.Text = f.EntireRow.Cells(, "E").Value       ' VBA

        Me.RejectID.Text = f.EntireRow.Cells(, "A").Value       ' RejectID

        ' CHANNELS
        Me.MailChannel.Text = f.EntireRow.Cells(, "F").Value    ' Mail
        Me.WebChannel.Text = f.EntireRow.Cells(, "G").Value     ' Web
        Me.PhoneChannel.Text = f.EntireRow.Cells(, "H").Value   ' Phone


        ' get sample of pic from reject folder
        RejectSamples.Image2.Picture = LoadPicture(ThisWorkbook.Path & "\RejectExamples\" & RejectTitleNm.Value & ".jpg")

        ' get sample of pic from VAST folder
        Vexamples.VASTEx.Picture = LoadPicture(ThisWorkbook.Path & "\VASTScreens\" & RejectTitleNm.Value & ".jpg")

    Else

        MsgBox "please check your input", vbExclamation, "No match found"

    End If

End Sub

这篇关于如果没有图片匹配,则显示msg框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆