我是VBA的新手,我正在进行下面的任务
constexpr int power10(int n)
{
if (n == 0)
return 1;
return 10 * power10(n - 1);
}
template <int SIZE>
constexpr int v(const char (&definition)[SIZE], int INDEX)
{
// error: 'definition' is not a constant expression
constexpr char c = definition[INDEX];
if (INDEX >= 0)
{
if constexpr (c >= '0' && c <= '9')
{
return v(definition, INDEX - 1) + (power10(SIZE - INDEX - 2) * (c - '0'));
}
else
{
return 0 + v(definition, INDEX - 1);
}
}
return 0;
}
template <int SIZE>
constexpr int f(const char (&definition)[SIZE])
{
return v(definition, SIZE - 2);
}
enum operating_system : bool
{
// error: enumerator value for 'iOS' is not an integer constant
iOS = f(TO_STRING(__APPLE__)),
// error: enumerator value for 'Windows' is not an integer constant
Windows = f(TO_STRING(__MINGW32__)),
// error: enumerator value for 'Linux' is not an integer constant
Linux = f(TO_STRING(__linux__)),
};
我想从nPath = "Root\zTrash - No longer needed\NOC\NOC"
删除\NOC
,以便只显示nPath
。
我正在使用此代码:
Root\zTrash - No longer needed
但我只得到了NOC
答案 0 :(得分:2)
这个怎么样?
Left(nPath, InStr(nPath, "\NOC") - 1)
<小时/> 您正在使用
InStrRev
查找 last \
- 这不是您想要的。将InStr
与\NOC
一起使用,即可找到\NOC
的第一个实例
答案 1 :(得分:1)
您可以分两个阶段完成:
java.lang.RuntimeException: Unable to start activity ComponentInfo{class path}: java.lang.IllegalArgumentException: column '_data' does not exist
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by java.lang.IllegalArgumentException: column '_data' does not exist
at android.database.AbstractCursor.getColumnIndexOrThrow(AbstractCursor.java:333)
at android.database.CursorWrapper.getColumnIndexOrThrow(CursorWrapper.java:87)
at com.package.SaveImageActivity.getRealPathFromURI()
at com.package.SaveImageActivity.onCreate()
at android.app.Activity.performCreate(Activity.java:6672)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)