首页 \ 问答 \ VBA - 计算并打印许多行的答案(VBA - calculate and print answer for many rows)

VBA - 计算并打印许多行的答案(VBA - calculate and print answer for many rows)

我仍然是vba的新手,我正在编写一个宏来计算两列中两个日期之间的时间,使用dateDiff然后打印它旁边的单元格中的差异。 我也想做一个直到空

A列保存开始日期B列保存结束日期C列将保留答案

我有一些有用的代码,但大部分内容是为了理解宏的目标和需求而改变的。

Range("A2").Select
Do Until IsEmpty(ActiveCell)
 For i = 2 To 25
  date1 = ["A" & i]
  date2 = ["B" & i]
  answer = DateDiff("n", date1, date2)
  "C" & i = answer
 next i
Loop

我感谢任何帮助!


I am still new to vba and am writing a macro to calculate the time between two dates in two columns using dateDiff then print the difference in the cell next to it. i would also like do use a do until empty

Column A holds the start date Column B holds the end date Column C will hold the answer

i have some useful code but most of it is written to understand the goal of the macro and needs changed.

Range("A2").Select
Do Until IsEmpty(ActiveCell)
 For i = 2 To 25
  date1 = ["A" & i]
  date2 = ["B" & i]
  answer = DateDiff("n", date1, date2)
  "C" & i = answer
 next i
Loop

I appreciate any help!


原文:https://stackoverflow.com/questions/44440955
更新时间:2022-03-23 09:03

最满意答案

尝试将您的客户端代码更改为:

<script src="/socket.io/socket.io.js"></script>
<script>
    var socket = io.connect();
    socket.on("connect", function() {
        socket.on('news', function (data) {
            socket.emit('my other event', { my: 'data' });
        });
    });
</script>

此外,为了能够转到/api/1...您需要注册相应的app.get ,例如app.get("/api/*", ... ,它将处理所有连接to /api/...否则预计您将收到404错误。


Try to change your client code to:

<script src="/socket.io/socket.io.js"></script>
<script>
    var socket = io.connect();
    socket.on("connect", function() {
        socket.on('news', function (data) {
            socket.emit('my other event', { my: 'data' });
        });
    });
</script>

Also, in order to be able to go to /api/1... you need to register the corresponding app.get, e.g. as app.get("/api/*", ..., which would handle all the connections to /api/.... Otherwise it is expected that you will be getting the 404 error.

相关问答

更多
  • 改变这个: app.listen(3000); 至: server.listen(3000); app.listen()创建一个新的,不同的服务器,所以你连接到socket.io的服务器不是实际监听的服务器,因此你的socket.io服务器不活,不能处理/socket.io/socket.io.js请求或传入连接,如果脚本文件没有首先加载失败。 有关app.listen()详细信息以及为什么它不符合您的代码布局方式,请参阅此答案: websockets,express.js并且无法与服务器建立连接 注意 ...
  • Heroku要求您的应用程序侦听Heroku选择的端口。 Heroku将通过PORT环境变量在启动应用程序时告诉您的应用程序此端口。 如果您在任何其他端口上侦听,Heroku将忽略它并在60秒后终止您的应用程序。 您的用户的浏览器仍将使用端口80进行HTTP流量,将443用于HTTPS流量。 Heroku的路由层位于用户浏览器和应用程序之间,它将HTTP流量通过Heroku为您的应用程序指定的端口发送到您的应用程序。 Heroku requires that your application listens ...
  • 这是因为您错误地设置了它。 我遇到了同样的问题(相同的错误和基本的代码布局)。 您需要在页面的基本目录中执行npm install socket.io --save (与index.php文件所在的位置相同)。 然后你必须为快递( npm install express --save )做同样的事情。 您还必须更改服务器代码。 从以下位置更改io的创建: var express = require('express'); var app = express(); var http = requ ...
  • 我会尝试在socket io的初始化中包含端口号。 socket = io.connect('http://node.domain.com:8901) I would try including the port number in the initialization of socket io. socket = io.connect('http://node.domain.com:8901)
  • 因为某些原因 npm start 给了我上面的不一致的同时 node app.js 工作正常。 For some reason npm start gave me the above inconsistency while node app.js works fine.
  • 仅在app.js ,您将创建socket.io 三个实例,并再次在routes/index.js 。 整个应用程序中应该只有一个。 Express的常见设置如下所示: var app = require('express')(); var server = app.listen(app.get('port'), function () { console.log('server listening on port ' + server.address().port); }); var io = r ...
  • 尝试将您的客户端代码更改为: 编辑 :啊,我看到了问题:您的快速设置不正确。 var express = require('express'); var app = express(); var server = require('http').createServer(app); var io = require('socket.io')(serve ...
  • 您似乎正在创建两个单独的服务器,一个在您的www文件中: var server = http.createServer(app); 并且, index.js另一个: var server = require('http').Server(app); 你永远不会启动在index.js创建的那个,而且是socket.io所连接的那个,这就是你没有任何socket.io功能的原因。 绑定socket.io的服务器从未启动过。 你正在启动你的www文件,但它没有连接socket.io。 您需要创建一个服务器和一 ...
  • Socket.io NAMESPACES userType1.js: module.exports = function (io) { var nsp = io.of('/userType1'); nsp.on("connection", function (socket) { console.log("Connected to userType1"); }); } userType2.js module.exports = function (io) { ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)