我的代码是连接并与特定字段进行比较。如果相等,则在消息框中显示它。
它在单行中工作,但是当我创建循环时,输出不正确。
Sub postURLGFormat(ByRef msgPostFormat As String)
Dim URG, urgValue, urgCode, contentField, urlgField As String
Dim numRows, i As Long
numRows = Cells(Rows.Count, "A").End(xlUp).Row
contentField = Range("A1").Value
urlgField = Range("J1").Value
URG = "URG" & urgCode
For i = 2 To numRows
urgCode = Cells(i, "A").Value2
If URG = urgValue Then
msgPostFormat = msgPostFormat & Chr(149) & " " & urlgField & " " & URG & " is in proper format and with correct CT" & vbLf
Else
msgPostFormat = msgPostFormat & Chr(149) & " " & contentField & " " & urgCode & " is not aligned in " & urlgField & vbLf
End If
Next i
End Sub
答案 0 :(得分:1)
这里是一个示例循环,可满足您的需求。您有很多不需要的变量(除非稍后使用它们,否则未显示)。
此方法将循环遍历Column A
中最后使用的行所确定的范围。在For Each
循环中是字符串比较。
Option Explicit
Sub CheckVal()
Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1")
Dim MyRange As Range, MyCell As Range
Set MyRange = ws.Range("A2:A" & ws.Range("A" & ws.Rows.Count).End(xlUp).Row)
For Each MyCell In MyRange
If "URG" & MyCell.Text = MyCell.Offset(, 9).Text Then
'Do what you want here with CORRECT format
Else
'Do what you want here with INCORRECT format
End If
Next MyCell
End Sub
答案 1 :(得分:-5)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
// fixing portrait mode problem for SDK 26 if using windowIsTranslucent = true
if (Build.VERSION.SDK_INT == 26) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
<style name="SplashActivty" parent="AppTheme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
</style>
<!-- Splash screen -->
<activity
android:name="edu.aku.family_hifazat.activities.SplashActivity"
android:label="@string/app_name"
android:screenOrientation="unspecified"
android:theme="@style/SplashActivty">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>