我有一个userform,当initilised在我们的服务器上搜索文件并通过以下方式填充组合框时:
public class EventReceiver extends BroadcastReceiver {
private File imageFile;
private Context mContext;
@Override
public void onReceive(final Context context, Intent intent) {
mContext=context;
takeScreenshot();
//you can execute some of your other code also
}
private void takeScreenshot() {
try {
String mPath = Environment.getExternalStorageDirectory().toString() +"\\/pic";
View v1 = FirstScreenActivity.mActivity.getWindow().getDecorView().getRootView();
v1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(v1.getDrawingCache());
v1.setDrawingCacheEnabled(false);
imageFile = new File(mPath);
FileOutputStream outputStream = new FileOutputStream(imageFile);
int quality = 100;
bitmap.compress(Bitmap.CompressFormat.JPEG, quality, outputStream);
outputStream.flush();
outputStream.close();
} catch (Throwable e) {
e.printStackTrace();
}
}
有没有人知道我是否可以在后面的脚本中检索组合框的第一个值(在人口宏完成之后)。
我尝试过类似下面的内容(正如其他网站所建议的那样),但它不起作用。
cmbReportDateTime.AddItem Format(reportDateTime, "ddd dd-mmm-yy hh00")
完整代码:
me.cmbReportDateTime.Item(1).value
me.cmbReportDateTime.ItemData(1).value
答案 0 :(得分:0)
好的,你去吧
Public thestuff As String
Private Sub CommandButton1_Click()
With Me.ComboBox1
.AddItem "Stuff1"
.AddItem "Stuff2"
.AddItem "Stuff3"
.AddItem "Stuff4"
End With
thestuff = ComboBox1.List(0)
End Sub
Private Sub CommandButton2_Click()
Debug.Print ; thestuff
ActiveWorkbook.Sheets("Sheet1").Range("a1").Value = thestuff
End Sub
这可以解决问题并为您提供所需内容。注意" thestuff"发布在需要引用的模块上方。