我正在优化VBA中没有声明任何数据类型的宏,因此编译器将所有内容都作为变量进行了笨拙的处理.我正在处理科学测量,所以我需要精确度.我如何声明"Dim decAsdf为十进制"(不是那样但是正确的方法)?
我在Excel 2010中运行VBA宏并进行大量计算,因此数据类型非常重要,以保持宏执行时间尽可能低.
我的优化思路是让用户选择所有数字将被声明为的数据类型(同时指出每种数据类型的优缺点,准确性/灵活性与CPU密集度/宏执行时间之间的平衡).但是,当我运行宏时,我收到以下错误消息:
编译错误:
Type块外的语句无效
以下是代码的违规部分:
Ind2 As Double, BgrValP As Double, BgrRow As Double, M40eff As Double
Run Code Online (Sandbox Code Playgroud)
这是宏的相关部分:
' Develop fake data to at glance recognize whether program works.
' Source http://www.cpearson.com/excel/optimize.htm
Option Explicit
Private Sub Function1()
On Error GoTo ErrorHandler
Dim userChoice As Variant
Dim strPath As String, strFileN As String, strDirN As String, strRangeNOut As String, strRangeNIn As String, strFilename As String, strTLCorn As String, strBRCorn As String, strSelectedFile As String, strtemp_name As String
Dim lngCount As …Run Code Online (Sandbox Code Playgroud) 在VBA中,我可以Dim用这种简洁的方式在一行中将多个对象作为整数对象,还是只声明它d是一个整数?
Dim a, b, c, d As Integer
Run Code Online (Sandbox Code Playgroud) 我有一个VBA宏,它给了我错误信息.
Sub Function1()
' Give the user macro options based on how fast or slow the computer
' is using advanced conditional compiling
vuserChoice = MsgBox("This macro by default treats all numbers as decimals for maximum precision. If you are running this macro on an old computer, you may want to declare numbers as singles, to speed up the macro.")
MsgBox ("Decimal: recommended for maximum precision. Also slower." & vbNewLine & "Long: not recommended. Rounds to nearest integer." & vbNewLine …Run Code Online (Sandbox Code Playgroud) 我有一个使用Visual Studio 2015创建的用户窗体,我不知道该语言是什么.
根据我的经验,VS使用VB(Visual Basic),但这显然是从括号和分号用法判断的另一种语言.
这是什么语言?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Caesar_Cipher
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
}
}
}
Run Code Online (Sandbox Code Playgroud) 这是一个我希望的简单问题.我今天了解了IIf,并希望在某些情况下实现它以节省几行.
IIF(isnumeric(inputs), resume next, call notnum)
Run Code Online (Sandbox Code Playgroud)
这是红色意味着有语法错误,如何解决这个问题?我已经扫描了MSDN这篇文章,所以我不是在这里偷懒.
我正在创建一个概率宏,用户可以在其中输入纸牌游戏中的玩家数量。如果我输入字符串 (ex, Joe)、非整数 (ex, 15.67) 或小于 0 的整数 (ex, -25),则 InputBox 应该循环。但是,大于 0 的整数应终止循环。(无论用户输入如何,我都必须强制杀死 Excel 以停止 InputBox。)
一旦输入大于 0 的整数,我希望 InputBox 关闭/退出 Sub。我在这里做错了什么?
Sub GenerateCards()
Players = InputBox("How many players? Please enter an integer.")
Do Until TypeName(Players) = "Integer" And Players > 0 ' why does this loop even if both conditions are met (ex, Players=5?)
Players = InputBox("How many players? Please enter an integer.")
Loop
End Sub
Run Code Online (Sandbox Code Playgroud) C#是程序.
我正在编写一个程序,需要一个带有数字1-25的列表框作为条目.我确信有一种更简洁的方法可以做到这一点.
我怎样才能简化这段代码?
这是当前代码:
shiftListBox.Text = "";
shiftListBox.Items.Add("Random");
shiftListBox.Items.Add("1"); //is there a more concise way to write this- with a loop, for example?
shiftListBox.Items.Add("2");
shiftListBox.Items.Add("3");
shiftListBox.Items.Add("4");
shiftListBox.Items.Add("5");
shiftListBox.Items.Add("6");
shiftListBox.Items.Add("7");
shiftListBox.Items.Add("8");
shiftListBox.Items.Add("9");
shiftListBox.Items.Add("10");
shiftListBox.Items.Add("11");
shiftListBox.Items.Add("12");
shiftListBox.Items.Add("13");
shiftListBox.Items.Add("14");
shiftListBox.Items.Add("15");
shiftListBox.Items.Add("16");
shiftListBox.Items.Add("17");
shiftListBox.Items.Add("18");
shiftListBox.Items.Add("19");
shiftListBox.Items.Add("20");
shiftListBox.Items.Add("21");
shiftListBox.Items.Add("22");
shiftListBox.Items.Add("23");
shiftListBox.Items.Add("24");
shiftListBox.Items.Add("25");
Run Code Online (Sandbox Code Playgroud) 我有一个带有splashscreen元素的div.该元素将在页面加载时隐藏.但是,我还想确保启动画面显示至少x秒.
我知道这并不是所有应该被格式化为代码,但自动格式化程序让我这样做.
使用逻辑:显示启动画面至少x秒.如果该页面被加载,则隐藏此div.
此代码是加载页面后立即隐藏div的部分.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">
$(document).on("pageload",function(){
$('#splashscreen').hide();
});
</script>
<title>Thomas Shera</title>
</head>
<body>
<div id="splashscreen">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是我显示启动画面x秒的部分.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">
$(function() {
$("#div2").show().delay(x).hide();
});
</script>
<title>Thomas Shera</title>
</head>
<body>
<div id="splashscreen">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
所以基本上我问,我怎么能结合这两个jquery代码?
编辑:我现在正在尝试此代码,但仍然无法正常工作.
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js">
$(document).on("pageload",function(){
$('#splashscreen').hide();
});
$(function() {
$("splashscreen").show().delay(1000).hide();
});
</script>
<style type="text/css">
@import url(https://fonts.googleapis.com/css?family=Cutive+Mono);
.skills
{
font-family: 'Cultive Mono', monospace;
font-size: 400pt;
}
</style>
<title>Thomas Shera</title>
</head>
<body>
<div id="splashscreen"> …Run Code Online (Sandbox Code Playgroud) 我收到错误:
错误:(65,3)java:非法启动表达式
参考这一行:
public boolean equals(WordList wordList)
Run Code Online (Sandbox Code Playgroud)
我认为这是由字符串数组的范围引起的WordList[].但是,这似乎应该是可以接受的,因为我在构造函数中调用变量的实例.
我曾试图改变WordList[]建设public equals(WordList wordList),boolean equals(WordList wordList)以及其他的组合,虽然这些组合已经改变了错误信息.
码:
public class WordList
{
String[] words;
public int count;
//constructor
public WordList()
{
//create a size two array of strings and assign it to words instance variable
words = new String[2];
count = 0;
}
public int addWord(String word)
{
if(findWord(word) == -1) //word not in list
{
return count;
}
if(words.length == count)
{
String[] temp = …Run Code Online (Sandbox Code Playgroud) excel ×6
vba ×6
excel-vba ×5
arrays ×1
boolean ×1
c# ×1
excel-2007 ×1
excel-2010 ×1
goto ×1
html ×1
iif ×1
java ×1
jquery ×1
probability ×1