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
最满意答案
尝试将您的客户端代码更改为:
<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 correspondingapp.get
, e.g. asapp.get("/api/*", ...
, which would handle all the connections to/api/...
. Otherwise it is expected that you will be getting the 404 error.
相关问答
更多-
找不到Socket.io 404(Socket.io 404 Not Found)[2023-05-12]
改变这个: 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 ...
-
在Socket.io上连接404(404 on Socket.io connect)[2022-12-08]
尝试将您的客户端代码更改为: 编辑 :啊,我看到了问题:您的快速设置不正确。 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) { ...