问题列表 - 第48659页

VBA Excel二维数组

我试图找出如何声明一个二维数组,但到目前为止我找到的所有例子都是用set整数声明的.我正在尝试创建一个程序,它将利用两个2维数组,然后对这些数组执行简单的操作(例如查找差异或百分比).数组由Excel工作表中的数字填充(一组数字在Sheet1上,另一组在Sheet2上,两组具有相同的行数和列数).

由于我不知道有多少行或列,我将使用变量.

Dim s1excel As Worksheet
Dim s2excel As Worksheet
Dim s3excel As Worksheet
Dim firstSheetName As String
Dim secondSheetName As String
Dim totalRow As Integer
Dim totalCol As Integer
Dim iRow As Integer
Dim iCol As Integer

Set s1excel = ThisWorkbook.ActiveSheet

' Open the "Raw_Data" workbook
Set wbs = Workbooks.Open(file_path & data_title)
wbs.Activate
ActiveWorkbook.Sheets(firstSheetName).Select
Set s2excel = wbs.ActiveSheet

' Find totalRow, totalColumn (assumes there's values in Column A and Row 1 with no blanks)
totalRow = ActiveSheet.Range("A1").End(xlDown).Row
totalCol = …
Run Code Online (Sandbox Code Playgroud)

excel vba multidimensional-array

9
推荐指数
3
解决办法
14万
查看次数

来自另一种方法的Javadoc引用参数

我不想写冗余的javadoc注释.正如您所看到的,@param x在某种程度上是多余的.是否有一个javadoc标记来设置从@param x类中B@param x类中的引用,A或者我可以将它留下来?

/**
 * Class A constructor
 * 
 * @param x  position on x-axis
 */
public A(final int x) {
    this.x = x;
}

/**
 * Class B constructor
 * 
 * @param x  position on x-axis
 * @param y  position on y-axis
 */
public B(final int x, final int y) {
    super(x);
    this.y = y
}
Run Code Online (Sandbox Code Playgroud)

java javadoc

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

Java:使用BlockingQueue的生产者/消费者:使用消费者线程wait()直到另一个对象排队

我最近遇到了一些线程相关的问题,消费者需要积分.这是原始的,除了占用大量的cpu不断检查队列之外,它工作正常.这个想法是可以随便调用cuePoint,主线程继续运行.

import java.util.List;
import java.util.ArrayList;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;


public class PointConsumer implements Runnable {
    public static final int MAX_QUEUE_SIZE=500;

    BlockingQueue<Point> queue;

    public PointConsumer (){
        this.queue=new ArrayBlockingQueue<Point>(MAX_QUEUE_SIZE);
    }

     public void cuePoint(Point p){
        try{
            this.queue.add(p);
        }
        catch(java.lang.IllegalStateException i){}
    }
     public void doFirstPoint(){
        if(queue.size()!=0){
            Point p=queue.poll();
            //operation with p that will take a while
        }
    }

    public void run() {
        while(true){
                  doFirstPoint();
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

我试图通过每次调用cue函数时添加notify()来修复cpu问题,并将doFirstPoint()重新处理为这样的事情:

public void doFirstPoint(){

    if(queue.size()!=0){
            //operation with p that will take a while
    }
    else{
        try{
            wait(); …
Run Code Online (Sandbox Code Playgroud)

java multithreading producer-consumer blockingqueue

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

Excel宏 - 可以解释一下吗?

我是Excel宏的新手..

谁能告诉我这个宏有什么作用?

Sub People_Add_Document()

    prow = ActiveCell.row
    num = Cells(prow, 1).Value
    wshet = ActiveSheet.Name

    If (Val(num) > 0) _
       And (Cells(4, 1).Value = "#") _
       And (wsheet = People_wsheet) _
    Then
        people_select_link_to_Document process_wbook_path, prow
    End If
  End Sub



Sub people_select_link_to_Document(process_wbook_path, prow)

        If Len(Cells(prow, DocumentFile).Value) = 0 Then
        Fname = Application.GetOpenFilename("Document Files (*.doc;*.pdf),*.doc;*.pdf", 1, "Select the Document file..")

        If Fname <> False Then

            Cells(prow, DocumentFile).Value = Fname 'global path

        End If

    End If

End Sub
Run Code Online (Sandbox Code Playgroud)

excel vba excel-2003

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

使用PIL在python中旋转并将expand参数设置为true时指定图像填充颜色

我正在尝试使用PIL在Python中旋转图像并将expand参数设置为true.似乎当我的图像背景为黑色时,保存为bmp的结果图像将比我的图像具有白色背景要小得多,然后我用白色替换黑色.在任何一种情况下,我的原始图像总是有两种颜色,现在我需要文件大小很小,因为我将这些图像放在嵌入式设备上.

任何想法,如果我可以强制旋转填充另一种颜色扩展或如果有另一种方式旋转我的图片,以使其小?

python image colors rotation python-imaging-library

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

Linq表达式和扩展方法获取属性名称

我正在看这篇文章,它描述了在POCO属性之间进行数据绑定的简单方法:数据绑定POCO属性

Bevan的评论之一包括一个简单的Binder类,可用于完成此类数据绑定.它对我需要的东西很有用,但我想实现Bevan为改进课程所做的一些建议,即:

  • 检查是否已分配源和目标
  • 检查sourcePropertyName和targetPropertyName标识的属性是否存在
  • 检查两个属性之间的类型兼容性

此外,鉴于按字符串指定属性容易出错,您可以使用Linq表达式和扩展方法.然后而不是写作

Binder.Bind( source, "Name", target, "Name")
Run Code Online (Sandbox Code Playgroud)

你可以写

source.Bind( Name => target.Name);
Run Code Online (Sandbox Code Playgroud)

我很确定我可以处理前三个(尽管可以随意包含这些更改)但我不知道如何使用Linq表达式和扩展方法来编写代码而不使用属性名称字符串.

有小费吗?

以下是链接中的原始代码:

public static class Binder
{

    public static void Bind(
        INotifyPropertyChanged source,
        string sourcePropertyName,
        INotifyPropertyChanged target,
        string targetPropertyName)
    {
        var sourceProperty
            = source.GetType().GetProperty(sourcePropertyName);
        var targetProperty
            = target.GetType().GetProperty(targetPropertyName);

        source.PropertyChanged +=
            (s, a) =>
            {
                var sourceValue = sourceProperty.GetValue(source, null);
                var targetValue = targetProperty.GetValue(target, null);
                if (!Object.Equals(sourceValue, targetValue))
                {
                    targetProperty.SetValue(target, sourceValue, null);
                }
            };

        target.PropertyChanged +=
            (s, a) =>
            {
                var sourceValue = …
Run Code Online (Sandbox Code Playgroud)

.net c# data-binding poco system.componentmodel

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

麻烦编写内部内存android

void launchImageCapture(Activity context) {
    Uri imageFileUri = context.getContentResolver()
        .insert(Media.INTERNAL_CONTENT_URI, new ContentValues());
    m_queue.add(imageFileUri);
    Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

    i.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageFileUri); 
    context.startActivityForResult(i, ImportActivity.CAMERA_REQUEST); 
}
Run Code Online (Sandbox Code Playgroud)

以上代码一直有效,现在在insert()中为我生成了这个例外.

java.lang.UnsupportedOperationException: Writing to internal storage is not supported.
     at com.android.providers.media.MediaProvider.generateFileName(MediaProvider.java:2336)
     at com.android.providers.media.MediaProvider.ensureFile(MediaProvider.java:1851)
     at com.android.providers.media.MediaProvider.insertInternal(MediaProvider.java:2006)
     at com.android.providers.media.MediaProvider.insert(MediaProvider.java:1974)
     at android.content.ContentProvider$Transport.insert(ContentProvider.java:150)
     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:140)
     at android.os.Binder.execTransact(Binder.java:287)
     at dalvik.system.NativeStart.run(Native Method)
Run Code Online (Sandbox Code Playgroud)

这不是一个空间问题,我唯一改变的是一个不相关的类的包.另外,我重新启动了手机.

storage android exception android-contentresolver android-contentprovider

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

希望C#程序启动WPF应用程序

我发现需要从ac#program中启动一个WPF应用程序.我编写了一个名为eBrowse的简单WPF浏览器作为练习.然后,我被要求将它添加到已经在使用的ac#程序中.

我试过System.Diagnostics.Process.Start(@"C:\eBrowse");但它没用.

在网站上发现的另一种可能性:

myProcess.StartInfo.UseShellExecute = true;
// You can start any process, HelloWorld is a do-nothing example.
//myProcess.StartInfo.FileName = "C:\\HelloWorld.exe";
myProcess.StartInfo.FileName = @"C:\eBrowse";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.Start();
// This code assumes the process you are starting will terminate itself. 
// Given that is is started without a window so you cannot terminate it 
// on the desktop, it must terminate itself or you can do it programmatically
// from this application using the Kill method.
Run Code Online (Sandbox Code Playgroud)

我想知道是否可能无法从c#启动WPF应用程序.任何想法都会很棒.

c# wpf

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

如何以编程方式触发可拖动的行为

我在jQuery中创建了一个"2D滑块",其中通过在边界框内拖动"手柄"来同时操作2个参数.

我通过在父div中嵌套"handle"div并使用jQuery UI插件来实现拖拽行为来实现这一点.html看起来像:

<div class="Slider2d" id="grid_spacing_both">
    <div class="Slider2dHandle" id="grid_spacing_both_handle"></div>
</div>
Run Code Online (Sandbox Code Playgroud)

jQuery看起来像:

$(".Slider2dHandle").draggable({
    containment: "parent",
    scroll: false,
    drag: function(event, ui) {
        // calculates position and updates value input boxes
    }
});
Run Code Online (Sandbox Code Playgroud)

我还创建了一些代码,用于将句柄重新定位到父div中任何点击的位置:

$(".Slider2d").mousedown(function(event){
    // get location of click and reposition handle to click location
});
Run Code Online (Sandbox Code Playgroud)

我想要做的是修改上面的方法,以便用户可以单击父div中的某个位置,将句柄重新定位到单击位置,然后开始拖动句柄而不用鼠标按钮.基本上,我需要找到一种以编程方式触发拖动功能的方法.

我在这里这里找到了一些建议,并尝试通过更改上述方法来实现他们的建议:

$(".Slider2d").mousedown(function(event){
    // get location of click and reposition handle to click location
    handle = $(".Slider2d").children(".Slider2dHandle");
    handle.trigger(event);
});
Run Code Online (Sandbox Code Playgroud)

这在最技术意义上有效,但它超级慢,我收到一些来自Safari的错误消息告诉我"RangeError:超出最大调用堆栈大小".我正在考虑的是,当我在句柄上触发事件时,它会冒泡到父级,然后再次调用触发器,依此类推等等.我试图通过在.trigger()调用之前和之后向我的代码中抛出一个event.stopPropagation来阻止冒泡,但无济于事.

所以,如果有人对如何使这项工作有任何建议,我真的很感激.我在这里有一个备份计划,但在我看来这是不必要的复杂.

谢谢!

jquery jquery-ui jquery-ui-draggable

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

Oracle 11g具有幻像连接

我的机器本地安装了11g(Windows 7 64位).

当我从oracle断开所有客户端时(即没有运行sqlplus,没有运行weblogic)然后使用sqlplus重新连接并运行以下脚本:

SQL> set linesize 120
SQL> SELECT            s.sid,
  2                    s.serial#,
  3                    s.username,
  4                    s.program
  5    from v$session s
  6    where username is not null;
       SID    SERIAL# USERNAME                       PROGRAM
---------- ---------- ------------------------------ ----------------------------------------------------------------
       134      11274 FOO                         ORACLE.EXE (J000) <-- I want to remove this connection
       139      19140 MYADMIN                        sqlplus.exe       <-- My connection
       155       8941 FOO                         ORACLE.EXE (J001) <-- I want to remove this connection
SQL>
Run Code Online (Sandbox Code Playgroud)

所以我试图以编程方式删除我用蓝色标记的连接.

我使用以下内容:

SQL> ALTER SYSTEM DISCONNECT SESSION  134,11274  IMMEDIATE;
ALTER SYSTEM DISCONNECT SESSION …
Run Code Online (Sandbox Code Playgroud)

oracle plsql oracle11g

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