投稿者 shu  (社会人) 投稿日時 2011/7/5 22:00:32
        If Trg = "" Then
            TransRoman = RomanMap(0, idx)
        Else
            Dim RomanMapNum = RomanMap.GetUpperBound(0)
            Dim idxLast = -1
            For idxm = 1 To RomanMapNum - 1
                If Trg.EndsWith(RomanMap(idxm, 0)) Then
                    idxLast = idxm
                End If
            Next
            If idxLast >= 0 And idxLast < RomanMapNum Then
                Dim ret = RomanMap(idxLast, idx)

                '『っ』の判断
                If ret <> "" Then
                    Dim TrStr = RomanMap(idxLast, 0)
                    If TrStr.Length < Trg.Length Then
                        Trg = Trg.Substring(Trg.Length - TrStr.Length - 1, 1)
                        If TrStr.StartsWith(Trg) Then
                            Bef &= "っ"
                        End If
                    End If
                End If
                '2文字以上の場合最後の文字より前をBefに連結
                If ret.Length > 1 Then
                    Bef &= ret.Substring(0, ret.Length - 1)
                    ret = ret.Substring(ret.Length - 1)
                End If
                TransRoman = ret
            Else
                TransRoman = ""
            End If
            MyBase.Text = Bef & Aft
            MyBase.SelectionLength = 0
            MyBase.SelectionStart = Bef.Length
        End If

    End Function

    Private Function IsNN() As Boolean
        Dim SelSt = MyBase.SelectionStart
        Dim SelLen = MyBase.SelectionLength
        Dim Bef = If(SelSt > 0, MyBase.Text.Substring(0, SelSt), MyBase.Text)
        Dim Aft = If(SelSt + SelLen < TextLength, MyBase.Text.Substring(SelSt + SelLen), "")
        Dim ret = False

        If Bef.EndsWith("N") Then
            Bef = Bef.Substring(0, Bef.Length - 1)
            ret = True
        End If

        If ret Then
            MyBase.Text = Bef & Aft
            MyBase.SelectionLength = 0
            MyBase.SelectionStart = Bef.Length
        End If

        Return ret
    End Function
End Class