Bit연산
체크를 넣은 항목만 적용시키고 싶을 때
각 항목을 boolean으로 T/F로 정의하지 않고
비트 연산을 사용해서 각 자릿수의 0/1을 판단해서 1인 항목만을 적용시킴
예)font, fontsize, fontcolor, fontStyle, buttonColor, width, height,btnTxtPos
어떤 것에도 체크가 되지 않았을 때 메시지를 내보냄
'Before
'하나씩 T/F를 지정해주는 방식
Private bFontSizeBS As Boolean = False
Private bFontStyleBS As Boolean = False
Private bFontColorBS As Boolean = False
Private bBackColorBS As Boolean = False
Private bWidthBS As Boolean = False
Private bHeightBS As Boolean = False
Private bTxtPosBS As Boolean = False
체크를 넣어주는 처리에 각 항목을 true로 바꿔줌
If (bFontBS OrElse bFontColorBS OrElse bFontSizeBS OrElse bFontStyleBS OrElse bBackColorBS OrElse bWidthBS OrElse bHeightBS OrElse bTxtPosBS) = False Then
Dim strWarningMsg As String = dbSC.GetMessageString(msgName, 100)
Dim ret As DialogResult = MessageBox.Show(strWarningMsg, "", MessageBoxButtons.OK,
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
Exit Sub
End If
If bFontBS Then
defN.Font = BSFontName
End If
'After
'16진수 BIT연산으로 판단하는 방법
Private Const INT_Font As Integer = &H1
Private Const INT_FontSize As Integer = &H2
Private Const INT_FontColor As Integer = &H4
Private Const INT_FontStyle As Integer = &H8
Private Const INT_BackColor As Integer = &H10
Private Const INT_Width As Integer = &H20
Private Const INT_Height As Integer = &H40
Private Const INT_TxtPos As Integer = &H80
nRange = nRange Or INT_Height
If nRange = 0 Then
Dim strWarningMsg As String = dbSC.GetMessageString(msgName, 100)
Dim ret As DialogResult = MessageBox.Show(strWarningMsg, "dbSheetClient", MessageBoxButtons.OK,
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1)
Exit Sub
End If
If nRange And INT_Font Then
defN.Font = BSFontName
End If
'VB.NET FRAMEWORK' 카테고리의 다른 글
[vb.net]HASH SET Multiple PK 주키 설정하기 (0) | 2020.05.31 |
---|