小编Ada*_*sen的帖子

从VBA中的其他模块调用子例程

可以从一个Module到另一个调用一个函数吗?

我有以下代码:

Sub MAIN()
    Call IDLE
End Sub
Run Code Online (Sandbox Code Playgroud)
  • MAIN 位于 Module1
  • IDLE位于Module2并定义为:Sub IDLE()

vba module call

54
推荐指数
1
解决办法
20万
查看次数

window.onbeforeunload在页面刷新而不是页面关闭时执行

window.onbeforeunload当发生关闭事件时,我正在使用弹出确认对话框,但页面刷新时会出现确认对话框,并且不会在页面关闭时执行.

这是JavaScript代码:

<script language="JavaScript">
    window.onbeforeunload = confirmWinClose();
    function confirmWinClose() {
        var confirmClose = confirm('Close?');
        return confirmClose;
    }    
</script>
Run Code Online (Sandbox Code Playgroud)

我在Chrome,Firefox和Internet Explorer上尝试过它.

javascript onbeforeunload

10
推荐指数
2
解决办法
3万
查看次数

JavaFX中的按钮对齐方式

我用关闭按钮创建了这个JavaFX对话框:

final int xSize = 300;
final int ySize = 280;
final Color backgroundColor = Color.WHITE;
final String text = "SQL Browser Version 1.0";

final Stage aboutDialog = new Stage();
aboutDialog.initModality(Modality.WINDOW_MODAL);

Button closeButton = new Button("Close");
closeButton.setAlignment(Pos.BOTTOM_CENTER);

closeButton.setOnAction(new EventHandler<ActionEvent>() {
    @Override
    public void handle(ActionEvent arg0) {
        aboutDialog.close();
    }
});

Scene aboutDialogScene = new Scene(VBoxBuilder.create()
    .children(new Text(text), closeButton)
    .alignment(Pos.CENTER)
    .padding(new Insets(10))
    .build(), xSize, ySize, backgroundColor);

aboutDialog.setScene(aboutDialogScene);
aboutDialog.show();
Run Code Online (Sandbox Code Playgroud)

我想在对话框的底部显示按钮.我用它来设置对齐: closeButton.setAlignment(Pos.BOTTOM_CENTER);但由于某种原因,按钮显示在对话框的中心.你能告诉我怎么解决这个问题吗?

java javafx javafx-2

7
推荐指数
1
解决办法
3万
查看次数

如何以编程方式强制JavaFX应用程序关闭请求

javafx.stage.Window.setOnCloseRequest(EventHandler<WindowEvent> arg0)当我关闭我的应用程序时,我一直在使用运行一些代码.现在我想在我的代码中强制关闭请求,因此运行这个相同的算法.

我想stage.close(),Platform.exit()System.exit()无济于事; 他们都关闭了应用程序,但直接关闭.没有机器人按下,有没有顺利的方法做到这一点Alt + F4?(我也可以想象从算法中创建一个函数并调用它setOnCloseRequest()并在其他任何地方调用它).

javafx

7
推荐指数
1
解决办法
1万
查看次数

如何以编程方式模拟Java FX中的箭头键按下

我想让我的JFX应用程序模拟箭头键按下(当它们在TextField中注册时),但我无法弄清楚如何发送除字符串或字节之外的任何内容.

我想象的是这样的:

static EventHandler<KeyEvent> KEY() {
    E = new EventHandler<KeyEvent>() {
        @Override
        public void handle(KeyEvent ke) {
            if (ke.getCode().equals(KeyCode.UP)) {
                try {
                    //someObject.SimulateKeyPress(KeyCode.UP);

                    //OR

                    //coolObject.SendKey((char)KEY_UPKEY));
                } catch (Exception ex) {
                    //Teleport goats
                }
            }
        }
    };

    return E;
}
Run Code Online (Sandbox Code Playgroud)

java javafx keypress

6
推荐指数
1
解决办法
4944
查看次数

"十进制"中的问号是什么?意思?

我正在关注有关MVC4 asp.net的教程.教程使用Decimal如下:

     public Decimal x{ set; get; }
     public Decimal? y{ set; get; }
Run Code Online (Sandbox Code Playgroud)

使用? 后是什么意思Decimal

c#

3
推荐指数
1
解决办法
6295
查看次数

Eclipse Neon (Java EE IDE) Javascript 编辑器损坏

问题描述

使用JavaScript 编辑器打开文件 (app.js) 时出现错误:“编辑器无法初始化。”

细节:

java.lang.NoSuchMethodError: jdk.nashorn.internal.runtime.ECMAException.getEcmaError()Ljava/lang/Object;
    at org.eclipse.wst.jsdt.internal.esprima.EsprimaParser.parse(EsprimaParser.java:148)
    at org.eclipse.wst.jsdt.core.dom.ASTParser.createAST(ASTParser.java:651)
    at org.eclipse.wst.jsdt.internal.core.CompilationUnit.buildStructure(CompilationUnit.java:168)
    at org.eclipse.wst.jsdt.internal.core.Openable.generateInfos(Openable.java:243)
    at org.eclipse.wst.jsdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:538)
    at org.eclipse.wst.jsdt.internal.core.BecomeWorkingCopyOperation.executeOperation(BecomeWorkingCopyOperation.java:39)
    at org.eclipse.wst.jsdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:742)
    at org.eclipse.wst.jsdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802)
    at org.eclipse.wst.jsdt.internal.core.CompilationUnit.becomeWorkingCopy(CompilationUnit.java:122)
    at org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.createFileInfo(CompilationUnitDocumentProvider.java:975)
    at org.eclipse.ui.editors.text.TextFileDocumentProvider.connect(TextFileDocumentProvider.java:478)
    at org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitDocumentProvider.connect(CompilationUnitDocumentProvider.java:1190)
    at org.eclipse.ui.texteditor.AbstractTextEditor.doSetInput(AbstractTextEditor.java:4178)
    at org.eclipse.ui.texteditor.StatusTextEditor.doSetInput(StatusTextEditor.java:229)
    at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.doSetInput(AbstractDecoratedTextEditor.java:1466)
    at org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor.internalDoSetInput(JavaEditor.java:2173)
    at org.eclipse.wst.jsdt.internal.ui.javaeditor.JavaEditor.doSetInput(JavaEditor.java:2146)
    at org.eclipse.wst.jsdt.internal.ui.javaeditor.CompilationUnitEditor.doSetInput(CompilationUnitEditor.java:1306)
    at org.eclipse.ui.texteditor.AbstractTextEditor$5.run(AbstractTextEditor.java:3154)
    at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:437)
    at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:353)
    at org.eclipse.ui.internal.WorkbenchWindow$14.run(WorkbenchWindow.java:2184)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2180)
    at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3172)
    at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3197)
    at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:362)
    at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:319)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:54)
    at …
Run Code Online (Sandbox Code Playgroud)

javascript eclipse development-environment eclipse-neon jakarta-ee

3
推荐指数
1
解决办法
5519
查看次数

如果与有条件的速度比较

我有这个想法,我会使用条件运算符将我的一些if块转换为单行.但是,我想知道是否存在速度差异.我运行了以下测试:

static long startTime;
static long elapsedTime;
static String s;

public static void main(String[] args) {
    startTime = System.nanoTime();
    s = "";
    for (int i= 0; i < 1000000000; i++) {
        if (s.equals("")) {
            s = "";
        }
    }

    elapsedTime = System.nanoTime() - startTime;

    System.out.println("Type 1 took this long: " + elapsedTime + " ns");

    startTime = System.nanoTime();
    s = "";
    for (int i= 0; i < 1000000000; i++) {
        s = (s.equals("") ? "" : s);
    }

    elapsedTime = …
Run Code Online (Sandbox Code Playgroud)

java benchmarking if-statement conditional-operator microbenchmark

2
推荐指数
2
解决办法
361
查看次数

在动态插入javascript到页面时如何防止"操作不安全"警告?

我正在尝试动态地将一个元,链接和脚本块添加到jQuery Mobile页面.

该脚本包含一条规则,我通过javascript添加到CSS样式表(不幸的是必须像这样).

看起来像这样:

<script type="text/javascript"
if ('addRule' in sheet) {
sheet.addRule(".splash:before",
  "background: url("' + x + '") no-repeat center center fixed; " +
  "-webkit-background-size: 100%; -moz-background-size: 100%; " +
  "-o-background-size: 100%; background-size: 100%; " +
  "-webkit-background-size: cover; -moz-background-size: cover;" +
  "-o-background-size: cover; background-size: cover;", 0);
} else if ('insertRule' in sheet) {
sheet.insertRule(".splash:before { " +
  "background: url("' + x + '") no-repeat center center fixed; " +
  "-webkit-background-size: 100%; -moz-background-size: 100%; " +
  "-o-background-size: 100%; background-size: 100%; " …
Run Code Online (Sandbox Code Playgroud)

javascript security jquery dynamic

1
推荐指数
1
解决办法
9913
查看次数

为什么这个程序会创建这样的输出?

为什么这个程序会写45,125和300?我知道45和300,我对一个案例sum1(arrD)更感兴趣,程序写入125.我希望有人知道.

#include <iostream>

using namespace std;

class B{
public:
    B(): b(bCounter++){}
    int b;
    static int bCounter;
};

int B::bCounter = 0;

class D : public B{
public:
    D() : d(bCounter){}
    int d;
};

const int N = 10;
B arrB[N];
D arrD[N];


int sum1(B* arr){
    int s = 0;
    for (int i=0; i<N; i++) s+=arr[i].b;
    return s;
}

int sum2 (D* arr){
    int s = 0;
    for (int i = 0; i<N; i++) s+= arr[i].b + arr[i].d;
    return s;
} …
Run Code Online (Sandbox Code Playgroud)

c++ arrays output

0
推荐指数
2
解决办法
125
查看次数