拥抱影子

文章 评论 浏览 29

拥抱影子 2025-02-20 23:50:54

在此处的直接答案之外,应该注意python 2和3之间的另一个关键区别。 几乎所有主要差异都涉及您何时应该使用任何一个版本。 此博客文章也做得很好目前

​python语言。在继续沿Python 3路线继续前,您应该考虑上述文章。您不仅需要更改某些语法,还需要考虑哪些软件包可供您使用(Python 2的优势)以及可以在您的代码中进行的潜在优化(Python 3的优势) 。

Outside of the direct answers here, one should note the other key difference between python 2 and 3. The official python wiki goes into almost all of the major differences and focuses on when you should use either of the versions. This blog post also does a fine job of explaining the current python universe and the somehow unsolved puzzle of moving to python 3.

As far as I can tell, you are beginning to learn the python language. You should consider the aforementioned articles before you continue down the python 3 route. Not only will you have to change some of your syntax, you will also need to think about which packages will be available to you (an advantage of python 2) and potential optimizations that could be made in your code (an advantage of python 3).

“语法”是什么:在呼叫到“ print”中缺少括号。在python中的意思?

拥抱影子 2025-02-20 19:22:24

要出口:

会议1:

let user = gun.user() 
user.create('Bob','password123',console.log) 
user.auth('Bob' ,'password123',console.log) 

JSON.stringify(user._.sea) // prompt user to export / "download"

导入:

会议2:

let user = gun.user() 
let imported_JSON //Prompt user to import JSON as imported_JSON
let pair = JSON.parse(imported_JSON)
user.auth(pair,console.log) // user now authorised on session 2

To export:

Session 1:

let user = gun.user() 
user.create('Bob','password123',console.log) 
user.auth('Bob' ,'password123',console.log) 

JSON.stringify(user._.sea) // prompt user to export / "download"

To import:

Session 2:

let user = gun.user() 
let imported_JSON //Prompt user to import JSON as imported_JSON
let pair = JSON.parse(imported_JSON)
user.auth(pair,console.log) // user now authorised on session 2

导出枪支验证凭证,用于在不同的设备上登录/在不同的会话中

拥抱影子 2025-02-20 03:01:09

我的最终解决方案是不使用SystemD。随着Windows 11的发布,WSL已添加了一项新功能,以在WSL启动上运行脚本。如果您从Microsoft Store安装WSL(需要KB5020030),则此功能现在也可供Windows 10用户使用,该功能应在可选更新下可用)。

创建file/etc/wsl.conf,

[boot]
command = bash /etc/[path to startup script]

在我的情况下,我使用了路径“ /etc/wsl-services-start.sh”此shell脚本仅

service apache2 start
service mysql start

启动apache2,而mysql是我唯一需要的systemd,所以这对我来说很好。

My final solution was to just not use systemd. With the release of Windows 11, a new feature has been added to WSL to runs scripts on WSL startup. This feature is now also available to Windows 10 users if you install WSL from the Microsoft Store (requires KB5020030, which should be available under Optional Updates).

create the file /etc/wsl.conf and the following

[boot]
command = bash /etc/[path to startup script]

in my case I used the path "/etc/wsl-services-start.sh" This shell script contains only

service apache2 start
service mysql start

Starting apache2 and mysql was the only thing I needed systemd for, so this works fine for me.

Ubuntu升级后WSL2 VSCODE不会加载 - 工作正常1年

拥抱影子 2025-02-19 19:20:34

Metadaitem是一个结构,AFAIK您无法在XAML中初始化结构。

我还建议您在样本中创建一个metadaitem的集合。

也就是说,我使用附加的属性建立了此代码,并实现了您要做的事情。命名是冗长的,但我认为在这种情况下,我会更容易获得它的代表。我希望这会有所帮助。

metadatacontrolextension.cs

using CommunityToolkit.WinUI.UI.Controls;
using Microsoft.UI.Xaml;
using System.Collections.Generic;

namespace MetadataControlExtension;

public class MetadataControlExtensionItem
{
    public string Label { get; set; } = string.Empty;
}

public class MetadataControlExtensionItemList : List<MetadataControlExtensionItem>
{
}

public class MetadataControlExtension : DependencyObject
{
    public static IEnumerable<MetadataControlExtensionItem> GetItemsSource(DependencyObject obj)
    {
        return (IEnumerable<MetadataControlExtensionItem>)obj.GetValue(ItemsSourceProperty);
    }

    public static void SetItemsSource(DependencyObject obj, IEnumerable<MetadataControlExtensionItem> value)
    {
        obj.SetValue(ItemsSourceProperty, value);
    }

    public static readonly DependencyProperty ItemsSourceProperty =
        DependencyProperty.RegisterAttached(
            "ItemsSource",
            typeof(IEnumerable<MetadataControlExtensionItem>),
            typeof(MetadataControlExtension), new PropertyMetadata(0, OnItemsSourcePropertyChanged));

    private static void OnItemsSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        if (d is MetadataControl metadataControl && e.NewValue is IEnumerable<MetadataControlExtensionItem> itemsSource)
        {
            List<MetadataItem> metadataItems = new();

            foreach (MetadataControlExtensionItem item in itemsSource)
            {
                metadataItems.Add(new MetadataItem() { Label = item.Label });
            }

            metadataControl.Items = metadataItems;
        }
    }
}

mainwindow.xaml

<Window
    x:Class="MetadataControlTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
    xmlns:ex="using:MetadataControlExtension"
    mc:Ignorable="d">

    <Grid>
        <controls:MetadataControl>
            <ex:MetadataControlExtension.ItemsSource>
                <ex:MetadataControlExtensionItemList>
                    <ex:MetadataControlExtensionItem Label="1st Item"/>
                    <ex:MetadataControlExtensionItem Label="2nd Item"/>
                    <ex:MetadataControlExtensionItem Label="3rd Item"/>
                    <ex:MetadataControlExtensionItem Label="4th Item"/>
                    <ex:MetadataControlExtensionItem Label="5th Item"/>
                </ex:MetadataControlExtensionItemList>
            </ex:MetadataControlExtension.ItemsSource>
        </controls:MetadataControl>
    </Grid>

</Window>

MetadataItem is a struct and AFAIK you can't initialize a struct in XAML.

I also recommend that you create a collection of MetadataItems like it in the samples.

That said, I build up this code using an Attached Property and achieved what you are trying to do. The namings are verbose but I think I'd be easier to get what it represents in this case. I hope this helps.

MetadataControlExtension.cs

using CommunityToolkit.WinUI.UI.Controls;
using Microsoft.UI.Xaml;
using System.Collections.Generic;

namespace MetadataControlExtension;

public class MetadataControlExtensionItem
{
    public string Label { get; set; } = string.Empty;
}

public class MetadataControlExtensionItemList : List<MetadataControlExtensionItem>
{
}

public class MetadataControlExtension : DependencyObject
{
    public static IEnumerable<MetadataControlExtensionItem> GetItemsSource(DependencyObject obj)
    {
        return (IEnumerable<MetadataControlExtensionItem>)obj.GetValue(ItemsSourceProperty);
    }

    public static void SetItemsSource(DependencyObject obj, IEnumerable<MetadataControlExtensionItem> value)
    {
        obj.SetValue(ItemsSourceProperty, value);
    }

    public static readonly DependencyProperty ItemsSourceProperty =
        DependencyProperty.RegisterAttached(
            "ItemsSource",
            typeof(IEnumerable<MetadataControlExtensionItem>),
            typeof(MetadataControlExtension), new PropertyMetadata(0, OnItemsSourcePropertyChanged));

    private static void OnItemsSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
    {
        if (d is MetadataControl metadataControl && e.NewValue is IEnumerable<MetadataControlExtensionItem> itemsSource)
        {
            List<MetadataItem> metadataItems = new();

            foreach (MetadataControlExtensionItem item in itemsSource)
            {
                metadataItems.Add(new MetadataItem() { Label = item.Label });
            }

            metadataControl.Items = metadataItems;
        }
    }
}

MainWindow.xaml

<Window
    x:Class="MetadataControlTest.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
    xmlns:ex="using:MetadataControlExtension"
    mc:Ignorable="d">

    <Grid>
        <controls:MetadataControl>
            <ex:MetadataControlExtension.ItemsSource>
                <ex:MetadataControlExtensionItemList>
                    <ex:MetadataControlExtensionItem Label="1st Item"/>
                    <ex:MetadataControlExtensionItem Label="2nd Item"/>
                    <ex:MetadataControlExtensionItem Label="3rd Item"/>
                    <ex:MetadataControlExtensionItem Label="4th Item"/>
                    <ex:MetadataControlExtensionItem Label="5th Item"/>
                </ex:MetadataControlExtensionItemList>
            </ex:MetadataControlExtension.ItemsSource>
        </controls:MetadataControl>
    </Grid>

</Window>

如何使用witui 3将元数据对照项目绑定到XAML中的收藏

拥抱影子 2025-02-19 05:02:07

您可以使用querySelectorall选择所有父母。您发布的代码未正确格式化,因此这就是我可以从中得到的。

function close() {
    let parents = document.querySelectorAll('.container_blur')'
    if ( parents.length < 1 ) return;
    parents.forEach(parent => {

       setTimeout(function () {
          parent.style.opacity = 0;
          parent.style.transition = 'opacity 0.3s ease-out';
       }, 10);

       setTimeout(function () {
          parent.style.display = 'none';
       }, 300);

    });
}

You can select all parents using querySelectorAll. The code you posted was not formatted properly, so this is what I could make out of it.

function close() {
    let parents = document.querySelectorAll('.container_blur')'
    if ( parents.length < 1 ) return;
    parents.forEach(parent => {

       setTimeout(function () {
          parent.style.opacity = 0;
          parent.style.transition = 'opacity 0.3s ease-out';
       }, 10);

       setTimeout(function () {
          parent.style.display = 'none';
       }, 300);

    });
}

如何在多个父母中使用按钮孩子?

拥抱影子 2025-02-19 03:19:33

OR(||)操作员始终返回首先真实值yellow在您的情况下。

如果您只想在这两个之间进行选择,则可以将它们放入数组中并使用 math.random() 生成一个随机数。如果此数字小于0.5,则可以选择第一个数字,如果它更大,请选择第二个:

console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])

您可以这样更新代码:

.setColor(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])

The OR (||) operator always returns the first truthy value, YELLOW in your case.

If you only want to choose between those two, you can put them in an array and use Math.random() to generate a random number. If this number is less than 0.5, you can choose the first one, if it's larger, choose the second one:

console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])
console.log(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])

You can update your code like this:

.setColor(['YELLOW', 'RED'][Math.random() < 0.5 ? 0 : 1])

我希望我的嵌入颜色设置在2种不同的颜色之间

拥抱影子 2025-02-18 22:36:29

我认为对地图方法的方法有误解。该方法通常用于原始值保持不变的数据转换。您在这里真正做的是造成副作用,MAP方法在这里根本没有帮助您。

只需使用循环的即可。这并不是说您使用地图和插入器保存击键。

但是,您提到您有一个vec&lt;&amp; vec&gt;。拥有这种类型似乎不适合您的目的。克隆整个vec只是为了添加1个元素,对于性能是可怕的。

我看到了2个选择:要么拥有完全拥有,即vec&lt; vec&gt;,要么只是使Inner vec sable可变,如vec&amp; mut中vec&gt;

这是第一个选项,我认为这是最惯用的:

fn main() {
    let mut vec_of_strings = vec![
        vec!["a1", "b2", "c3"], 
        vec!["d1", "e2", "f3"], 
        vec!["g1", "h2", "i3"]
    ];
 
    for vec in vec_of_strings.iter_mut() {
        vec.push("something");
    }
    
    println!("{vec_of_strings:?}");
}

如果以拥有形式的形式不可接受,那么另一种选择是使用vec&&amp&amp; mut vec vec&gt;

fn main() {
    fn main() {
    let mut vec_of_strings = vec![
        vec!["a1", "b2", "c3"], 
        vec!["d1", "e2", "f3"], 
        vec!["g1", "h2", "i3"]
    ];
    
    //suppose somehow a function gave you this:
    let vec_of_mut_strings: Vec<&mut Vec<_>> = vec_of_strings
        .iter_mut()
        .collect();
    
    for vec in vec_of_mut_strings {
        vec.push("something");
    }
    
    //notice that the original vec_of_strings change
    println!("{vec_of_strings:?}");
}
}

I think there's a misunderstanding on what the map method was made for. This methodis generally used for data transformations where the original values remain unchanged. What you are really doing here is causing a side effect, and the map method does not help you at all here.

Just use a for loop. It's not like you're saving keystrokes by using map and interators.

However, you mentioned you have a Vec<&Vec>. Having this type seems unfit for your purpose. Cloning the entire vec just to add 1 element is terrible for performance.

I see 2 choices: either have it fully owned, i.e. Vec<Vec>, or just make the inner Vecs mutable, as in Vec<&mut Vec>.

This is the first option, and I think this is the most idiomatic:

fn main() {
    let mut vec_of_strings = vec![
        vec!["a1", "b2", "c3"], 
        vec!["d1", "e2", "f3"], 
        vec!["g1", "h2", "i3"]
    ];
 
    for vec in vec_of_strings.iter_mut() {
        vec.push("something");
    }
    
    println!("{vec_of_strings:?}");
}

If having it in an owned form is not acceptable, then another option is to use Vec<&mut Vec>:

fn main() {
    fn main() {
    let mut vec_of_strings = vec![
        vec!["a1", "b2", "c3"], 
        vec!["d1", "e2", "f3"], 
        vec!["g1", "h2", "i3"]
    ];
    
    //suppose somehow a function gave you this:
    let vec_of_mut_strings: Vec<&mut Vec<_>> = vec_of_strings
        .iter_mut()
        .collect();
    
    for vec in vec_of_mut_strings {
        vec.push("something");
    }
    
    //notice that the original vec_of_strings change
    println!("{vec_of_strings:?}");
}
}

如何将其他元素推向Vec&lt;&amp; vec&lt; gt;&gt;?

拥抱影子 2025-02-18 18:46:10

我的代码的问题在于我正在使用和异步功能来获取我的数据,这并没有使数据显示。删除异步/等待解决问题。

const getEventsData = () => { 
    firebase.firestore().collection("Events").get().then((snapshot) => {
      const events = snapshot.docs.map(event => event.data());
      setEventsData(events)
      console.log(events)
    }).catch((e) => {
      console.log(e + "fetching error")
    })
  }

The problem with my code was that I was using and async function to get my data and that was not making the data to be shown. removing the async/await fixed the issue.

const getEventsData = () => { 
    firebase.firestore().collection("Events").get().then((snapshot) => {
      const events = snapshot.docs.map(event => event.data());
      setEventsData(events)
      console.log(events)
    }).catch((e) => {
      console.log(e + "fetching error")
    })
  }

完整日历未显示来自ReactJ中Firebase Firestore的事件

拥抱影子 2025-02-18 11:25:57

以下摘录来自 python关于self 的文档:

与Modula-3中一样,没有用于从其方法引用对象成员的速记(在Python中):方法函数是用代表对象的明确的第一个参数声明的,该函数由呼叫。

通常,方法的第一个论点称为自我。这无非是一种惯例:“自我”这个名字绝对没有特殊的意义。但是,请注意,通过不遵循《惯例》,您的代码可能不太对其他Python程序员读取,并且也可以想象,可以编写依赖此类约定的类浏览器程序。

有关更多信息,请参见 python文档教程

The following excerpts are from the Python documentation about self:

As in Modula-3, there are no shorthands [in Python] for referencing the object’s members from its methods: the method function is declared with an explicit first argument representing the object, which is provided implicitly by the call.

Often, the first argument of a method is called self. This is nothing more than a convention: the name self has absolutely no special meaning to Python. Note, however, that by not following the convention your code may be less readable to other Python programmers, and it is also conceivable that a class browser program might be written that relies upon such a convention.

For more information, see the Python documentation tutorial on classes.

“自我”参数的目的是什么?为什么需要它?

拥抱影子 2025-02-18 09:46:30

实际上,我认为它可以按预期工作,但是问题是,当尚未渲染这些类别的组件时,您正在尝试将单击处理程序放置。

您可以将这些jQuery代码放入函数中,将其导入您的React组件,然后在“ ComponentDidMount”中使用它,或者根据您使用的组件来使用空的依赖项(功能组件中的ComponentDidMount(例如ComponentDidmount))。

这样,您将确保渲染所有内容,并且可以将其放置在何处。

要检查此问题,请尝试在代码中使用console.log $(“。移动滤波器-btn”)。我希望它是不确定的。

这也不是好主意。它可能效果不太好,并且会产生很多错误或维护问题

Actually I assume that it works as expected, but the problem is, you are trying to put click handlers when components with those classes are not rendered yet.

You can put those jquery code into a function, import it to your react component and then use it in "componentDidMount" or useEffect with empty array of dependencies (works like componentDidMount in functional components) depending on which components you are using.

This way you will make sure that everything is rendered and you have where to put you click handlers.

To check this, try to console.log $(".mobile-filter-btn") in your code. I expect it to be undefined.

Also this is not good idea to bring jquery to react. It might work not very good with it and produce a lot of bugs or maintenance problems

是否可以在React JS中集成jQuery函数切换类

拥抱影子 2025-02-18 06:35:14

尝试直接运行应用程序:
dotnet serije.dll
(有正确的路径)

可能会出现一个错误:
找不到框架

Try to run app directly:
dotnet Serije.dll
(with correct paths)

Probably you'll get an error:
No framework found

(Code =退出,状态= 150)在Apache ASP.NET Core上

拥抱影子 2025-02-17 14:37:02

您需要提及,在向量的情况下,正在使用哪种标准C ++。例如带有[代码]的文件名,因此要为使用向量的[代码]创建可执行文件,终端代码将为 g ++ -Std = C ++ 11 Code.cpp&amp;&amp; ./a.out 执行并运行代码

You need to mention, which standard is under use of c++ in the case of vectors. Such as a file name with [code], so to create an executable file for [code] with vectors , terminal code will be g++ -std=c++11 code.cpp && ./a.out to execute and run the code

在C&#x2b;&#x2B中使用向量时,没有执行任何执行。使用VSCODE

拥抱影子 2025-02-17 06:56:01

这是一个快速而肮脏的解决方案。阈值似乎可以正常工作,但首先侵蚀了该区域并扩张它:

read_image (Image, 'D:/OneDrive - Subpixel d.o.o/Other/Stackoverflow/3/4e7Za.png')
rgb1_to_gray (Image, GrayImage)
equ_histo_image (GrayImage, ImageEquHisto)
threshold (ImageEquHisto, Regions, 145, 227)
fill_up (Regions, RegionFillUp)

erosion_circle (RegionFillUp, RegionErosion, 30.5)
dilation_circle (RegionErosion, RegionDilation, 30.5)

似乎颜色相机可以更好地解决您的问题,因为板条箱确实具有其他颜色。这是一个选择吗?

This is a quick and dirty solution. Thresholding seems to be working OK, but first erode the region and than dilate it:

read_image (Image, 'D:/OneDrive - Subpixel d.o.o/Other/Stackoverflow/3/4e7Za.png')
rgb1_to_gray (Image, GrayImage)
equ_histo_image (GrayImage, ImageEquHisto)
threshold (ImageEquHisto, Regions, 145, 227)
fill_up (Regions, RegionFillUp)

erosion_circle (RegionFillUp, RegionErosion, 30.5)
dilation_circle (RegionErosion, RegionDilation, 30.5)

It seems that the color camera would solve your problem much better, since the crate does have other color. Is this an option?

enter image description here

HALCON-从低对比度嘈杂图像中提取对象

拥抱影子 2025-02-17 04:54:04

返回字符串阵列中的变体数组值,

  • 无论执行此操作的动机如何(绩效问题,保持明确,以一行代码等执行等),您可以使用strarray函数。
Option Explicit
'Option Base 1 ' try and see that 'sArr' will always be zero-based
' To ensure that 'vArr' is zero-based, use 'vArr = VBA.Array("a", "b", "c")'.

Sub StrArrayTEST()
    
    ' Note that the 'vArr' parentheses are necessary to prevent
    ' 'Compile error: Type mismatch: array or user-defined type expected'...
    Dim vArr() As Variant: vArr = Array("a", "b", "c") ' try 'vArr = Array()'
    ' ... in the following 'sArr=...' line, where 'vArr' is highlighted.
    Dim sArr() As String: sArr = StrArray(vArr)
    
    ' The following line instead, doesn't compile with the same error
    ' (because of 'ByRef' in the function?) with 'Array' highlighted.
    'Dim sArr() As String: sArr = StrArray(Array("a", "b", "c"))
    
    Debug.Print "String Array Values"
    Debug.Print "Index", "String"
    
    Dim n As Long
    For n = 0 To UBound(sArr)
        Debug.Print n, sArr(n)
    Next n
    
    Debug.Print "Array   LB/UB       Vartype TypeName"
    Debug.Print "Variant [LB=" & LBound(vArr) & ",UB=" & UBound(vArr) & "]" _
        & " VT=" & VarType(vArr) & " TN=" & TypeName(vArr)
    Debug.Print "String  [LB=" & LBound(sArr) & ",UB=" & UBound(sArr) & "]" _
        & " VT=" & VarType(sArr) & " TN=" & TypeName(sArr)
    
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Purpose:      Returns the values from a variant array ('VariantArray'),
'               converted to strings, in a zero-based string array.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function StrArray( _
    VariantArray() As Variant) _
As String() ' 'ByVal VariantArray() As Variant' is not possible
    Const ProcName As String = "StrArray"
    Dim AnErrorOccurred As Boolean
    On Error GoTo ClearError ' turn on error-trapping
    
    Dim LB As Long: LB = LBound(VariantArray)
    Dim UB As Long: UB = UBound(VariantArray)
    
    Dim StringArray() As String: ReDim StringArray(0 To UB - LB)
    
    Dim n As Long
    
    For n = LB To UB
        StringArray(n - LB) = CStr(VariantArray(n))
    Next n
    
ProcExit:
    On Error Resume Next ' defer error-trapping (to prevent endless loop)
        If AnErrorOccurred Then
            ' Ensure the result is a string array.
            StrArray = Split("") ' LB = 0, UB = -1
        Else
            StrArray = StringArray
        End If
    On Error GoTo 0 ' turn off error-trapping (before exiting)
    
    Exit Function
ClearError:
    Debug.Print "'" & ProcName & "' Run-time error '" _
        & Err.Number & "':" & vbLf & "    " & Err.Description
    AnErrorOccurred = True
    Resume ProcExit ' continue error-trapping
End Function

Return Variant Array Values in a String Array

  • No matter what the motives are for doing this (performance issues, keeping it explicit, doing it in one line of code, etc.), you could use the StrArray function.
Option Explicit
'Option Base 1 ' try and see that 'sArr' will always be zero-based
' To ensure that 'vArr' is zero-based, use 'vArr = VBA.Array("a", "b", "c")'.

Sub StrArrayTEST()
    
    ' Note that the 'vArr' parentheses are necessary to prevent
    ' 'Compile error: Type mismatch: array or user-defined type expected'...
    Dim vArr() As Variant: vArr = Array("a", "b", "c") ' try 'vArr = Array()'
    ' ... in the following 'sArr=...' line, where 'vArr' is highlighted.
    Dim sArr() As String: sArr = StrArray(vArr)
    
    ' The following line instead, doesn't compile with the same error
    ' (because of 'ByRef' in the function?) with 'Array' highlighted.
    'Dim sArr() As String: sArr = StrArray(Array("a", "b", "c"))
    
    Debug.Print "String Array Values"
    Debug.Print "Index", "String"
    
    Dim n As Long
    For n = 0 To UBound(sArr)
        Debug.Print n, sArr(n)
    Next n
    
    Debug.Print "Array   LB/UB       Vartype TypeName"
    Debug.Print "Variant [LB=" & LBound(vArr) & ",UB=" & UBound(vArr) & "]" _
        & " VT=" & VarType(vArr) & " TN=" & TypeName(vArr)
    Debug.Print "String  [LB=" & LBound(sArr) & ",UB=" & UBound(sArr) & "]" _
        & " VT=" & VarType(sArr) & " TN=" & TypeName(sArr)
    
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Purpose:      Returns the values from a variant array ('VariantArray'),
'               converted to strings, in a zero-based string array.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function StrArray( _
    VariantArray() As Variant) _
As String() ' 'ByVal VariantArray() As Variant' is not possible
    Const ProcName As String = "StrArray"
    Dim AnErrorOccurred As Boolean
    On Error GoTo ClearError ' turn on error-trapping
    
    Dim LB As Long: LB = LBound(VariantArray)
    Dim UB As Long: UB = UBound(VariantArray)
    
    Dim StringArray() As String: ReDim StringArray(0 To UB - LB)
    
    Dim n As Long
    
    For n = LB To UB
        StringArray(n - LB) = CStr(VariantArray(n))
    Next n
    
ProcExit:
    On Error Resume Next ' defer error-trapping (to prevent endless loop)
        If AnErrorOccurred Then
            ' Ensure the result is a string array.
            StrArray = Split("") ' LB = 0, UB = -1
        Else
            StrArray = StringArray
        End If
    On Error GoTo 0 ' turn off error-trapping (before exiting)
    
    Exit Function
ClearError:
    Debug.Print "'" & ProcName & "' Run-time error '" _
        & Err.Number & "':" & vbLf & "    " & Err.Description
    AnErrorOccurred = True
    Resume ProcExit ' continue error-trapping
End Function

传递价值“直接”到VBA的数组

拥抱影子 2025-02-17 02:37:05

在创建表之前,您需要使用用户名和密码连接。

查看此博客以获取更多详细信息为我

You need to connect with username and password before creating tables.

check this blog for more details , it worked for me

用Docker组合初始化后,Oracle DB中的表不可见

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文