小编Max*_*Max的帖子

使用VB.NET检查Windows注册表中是否存在密钥

在VB.NET中,我可以在Windows注册表中创建一个键,如下所示:

My.Computer.Registry.CurrentUser.CreateSubKey("TestKey")
Run Code Online (Sandbox Code Playgroud)

我可以检查一个键中是否存在这样的:

If My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\MyKey", _
        "TestValue", Nothing) Is Nothing Then
    MsgBox("Value does not exist.")
Else
    MsgBox("Value exist.")
End If
Run Code Online (Sandbox Code Playgroud)

但是,如何检查注册表中是否存在具有特定名称的密钥

vb.net windows registry key-value registrykey

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

如何获得一个容器Div与自动高度和内部浮动div?

我有以下HTML

<style type="text/css">
<!--
.msg_ok{
    font-family: "Trebuchet MS";
    font-weight: bold;
    font-size: 16px;
    margin:0 auto;
    padding:10px;
    width:500px;
    height:auto;
    display:block;
}
.msg_ok{
    background-color:#DCFFB9;
    border:#003300 1px solid;
    color:#003500;
}
-->
</style>

      <div class="msg_ok" style="height:auto;">

        <div style="display:block;float:left;width:350px; height:auto;">
          <p>line 1<br>
          line2<br>
          line3<br>
          line4<br>
          line5<br>
          </p>
        </div>
        <div style="display:block;float:left;width:100px; height:auto;">
        <a href="#">Print</a>
        </div>

      </div>
Run Code Online (Sandbox Code Playgroud)

我得到了这个结果

在此输入图像描述

但是我怎么能得到如下结果,容器div的自动高度适合其大小与内部的浮动div?

在此输入图像描述

提前致谢

html css css-float

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

什么是与旧的CInt()VB方法对应的VB.NET方法?

我不想在我的代码中使用旧的Visual Basic方法,并且我对与旧的CInt()Visual Basic方法相对应的最新VB.NET方法感到困惑.

例如,

Dim n1 as Double : n1 = CInt(2.1111111) 'Gets only 2 without rounding it
Dim n2 as Double : n2 = CInt(2.7777777) 'Get only 2 without rounding it
Run Code Online (Sandbox Code Playgroud)

.net vb.net methods double type-conversion

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

在jQuery中,如何通过id属性的标签内的类子元素进行选择?

我有以下代码

<tr id="myid">
<td>
<div>
...
<a href="" class="myclass"></a>
<a href="" class="myclass"></a>
<a href="" class="myclass"></a>
<a href="" class="myclass"></a>
<a href="" class="myclass"></a>
...
</div>
</td>
</tr>
<tr id="anotherid">
<td>
<div>
...
<a href="" class="myclass"></a>
<a href="" class="myclass"></a>
<a href="" class="myclass"></a>
<a href="" class="myclass"></a>
<a href="" class="myclass"></a>
...
</div>
</td>
</tr>
Run Code Online (Sandbox Code Playgroud)

我正在尝试使用ID"myid"属性在标记TR中选择A标记但是以下代码不起作用:

$('#myid.myclass')
Run Code Online (Sandbox Code Playgroud)

如何使用TR ID选择A标签?

html jquery dom jquery-selectors

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

在MVC3中如何在</ body>之前将所有脚本移动到页面底部?

在MVC3中,我可以轻松地将jQuery脚本标记移动到页面底部"_Layout.vbhtml"

<script src="@Url.Content("~/Scripts/jquery-1.8.2.min.js")" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

但是在ASP.NET MVC3中使用编辑器模板创建Controller时,脚手架机制会将大量文件添加到Views文件夹中,如Create.cshtml,Delete.cshtml,Details.cshtml,Edit.cshtml和Index.cshtml等......它们是强类型的.

在这些View文件中,脚本标记位于其中<body>,但如何在</body>标记之前立即将这些标记添加到页面底部?

.net templates view scaffolding asp.net-mvc-3

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

如何在jQuery中包装具有不同类名的DIV标签?

可能重复:
如何将父元素添加到一组段落中?

我在文档中重复了以下HTML块

<!-- first block -->
<div class="first">
   My first div
</div>
<div class="second">
   My second div
</div>

<!-- second block -->
<div class="first">
   My first div
</div>
<div class="second">
   My second div
</div>

...
Run Code Online (Sandbox Code Playgroud)

如何用jQuery包装Divs以获得这样的结果HTML ...

<!-- first block -->
<div class="container">
   <div class="first">
      My first div
   </div>    
   <div class="second">
      My second div
   </div>
</div>

<!-- second block -->
<div class="container">
   <div class="first">
      My first div
   </div>    
   <div class="second">
      My second div
   </div>
</div>

...
Run Code Online (Sandbox Code Playgroud)

javascript jquery dom parent-child jquery-traversing

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

使用jQuery,如何在文档中绘制方形Div,单击视口中的一个点然后移动鼠标?

我想在DOM平方Div中绘制,单击视口中的随机点,然后用此效果移动鼠标...

http://www.vegabit.com/test/example_create_div_on_mouse_move.jpg

在jQuery中......没有任何插件......

先感谢您!

马克斯

html javascript jquery drawing

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

摧毁所有对象或让垃圾收集器完成工作更好吗?

我有一个像下面这样的功能:

Public Function testFunction(ByVal input_string As String) As String

    Dim s As New StringBuilder()
    Dim c As Char
    For i As Integer = 0 To input_string.Length - 1
        c = input_string.Chars(i)
        s.Append(c)
    Next
    Return s.ToString

End Function
Run Code Online (Sandbox Code Playgroud)

但我想知道是否最好明确销毁任何对象,如下所示:

    Public Function testFunction(ByVal input_string As String) As String

    Dim s As New StringBuilder()
    Dim c As Char
    For i As Integer = 0 To input_string.Length - 1
        c = input_string.Chars(i)
        s.Append(c)
    Next

    Dim t As String = s.ToString
    s = Nothing

    Return …
Run Code Online (Sandbox Code Playgroud)

.net vb.net garbage-collection memory-management

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

获取活动窗口的标题

我已经声明了以下WinAPI调用

<DllImport("USER32.DLL", EntryPoint:="GetActiveWindow", SetLastError:=True,
    CharSet:=CharSet.Unicode, ExactSpelling:=True,
    CallingConvention:=CallingConvention.StdCall)>
Public Shared Function GetActiveWindowHandle() As System.IntPtr
End Function

<DllImport("USER32.DLL", EntryPoint:="GetWindowText", SetLastError:=True,
    CharSet:=CharSet.Unicode, ExactSpelling:=True,
    CallingConvention:=CallingConvention.StdCall)>
Public Shared Function GetActiveWindowText(ByVal hWnd As System.IntPtr, _
                                            ByVal lpString As System.Text.StringBuilder, _
                                            ByVal cch As Integer) As Integer
End Function
Run Code Online (Sandbox Code Playgroud)

然后,我调用此子例程来获取活动窗口标题栏中的文本

Public Sub Test()
    Dim caption As New System.Text.StringBuilder(256)
    Dim hWnd As IntPtr = GetActiveWindowHandle()
    GetActiveWindowText(hWnd, caption, caption.Capacity)
    MsgBox(caption.ToString)
End Sub
Run Code Online (Sandbox Code Playgroud)

最后,我收到以下错误

无法在DLL"USER32.DLL"中找到名为"GetWindowText"的入口点

我该如何解决这个问题?

vb.net winapi user32 dllimport winforms

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

如何使用里面的元素声明一个可选的ArrayList ....

我有一个像这样的界面

Public Shared Function myfunction(Byval myvar as string, 
                               Optional ByVal myarray As ArrayList = Nothing) As String
Run Code Online (Sandbox Code Playgroud)

但是我想声明一个带有默认值的可选arraylist ......怎么做?

.net vb.net arraylist optional-parameters

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

在Vb.Net中,如何删除重复项但在列表中至少留下一个重复项?

我有一个List对象,我想删除重复的项目,但在列表中至少留下一个重复的项目;

我写了这样的东西但是我会优化这段代码以获得更好的性能,有更快的东西吗?

Const chars As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
Dim rnd As New Random()
Dim mylist As List(Of String) = Enumerable.Range(1, 100).Select(Function(i) chars(rnd.Next(0, chars.Length)).ToString).ToList

For n As Integer = mylist.Count - 1 To n = 0 Step -1

    'remove the item if it's duplicated
    'but leave at least one of the duplicated items in the list
    If mylist.IndexOf(mylist.Item(n), 0) < n Then
        mylist.RemoveAt(n)
    End If

Next
Run Code Online (Sandbox Code Playgroud)

.net vb.net arrays items list

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

如何在MySql中复制多个记录?

我在MySql数据库中有一个表"tb_products",字段"ID"作为主键和自动递增; 在SQL中通过ID选择多个记录并使用新增加的ID将它们复制到同一个表中的最佳做法是什么?

mysql sql field record

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