English 中文(简体)
视力基础中显示为预先界定的变数?
原标题:Convert string to pre-defined variable name in Visual Basic?

Im方案是视力基础的一个基本位置机器,希望利用机体随机选择每个位置的图像,显示每个位置的图像,并改变每个位置的梯度变量(因此,我可以随后检查点中的符号)。

The problem I m finding with a for loop is that the variables and objects for each slot have different names (slot1Name, slot2Name, slot3Name, lblSlot1, lblSlot2, lblSlot3, etc). Is there any way I could have something like:

currentSlotName = "slot" & i & "Name"

目前,这部法典在3个位置中的每一个位置都重复使用(有不同的变数和物体名称),而后者则效率极低。 我怎么能够放弃这一法典?

  Randomise numbers and assign images to slots based on random numbers, if the hold isn t on
      Slot 1
    If Not held1 Then
        slot1Value = Int(Rnd() * numbersGenerated + 0.5)
        Select Case slot1Value
            Case 0 To 5
                lblSlot1.Image = imgBanana
                slot1Name = "Banana"
            Case 6 To 11
                lblSlot1.Image = imgOrange
                slot1Name = "Orange"
            Case 12 To 16
                lblSlot1.Image = imgCherries
                slot1Name = "Cherries"
            Case 17 To 19
                lblSlot1.Image = imgSeven
                slot1Name = "Seven"
            Case 20
                lblSlot1.Image = imgBatman
                slot1Name = "Batman"
            Case Else
                lblSlot1.Text = "Error. slot1value = " & slot1Value
        End Select
    End If

I have searched around for this, but I m very new to Visual Basic, and want to keep my code as simple as possible.

最佳回答

解释太多。 你们需要学习。

问题回答

暂无回答




相关问题
Is Shared ReadOnly lazyloaded?

I was wondering when I write Shared ReadOnly Variable As DataType = New DataType() Or alternatively Shared ReadOnly Variable As New DataType() Is it lazy loaded or as the instance initializes? ...

Entertaining a baby with VB.NET

I would like to write a little application in VB.NET that will detect a baby s cry. How would I get started with such an application?

Choose Enter Rather than Pressing Ok button

I have many fields in the page and the last field is a dropdown with list of values. When I select an item in a dropdown and press Enter, it doesn t do the "Ok". Instead I have to manually click on Ok ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

Set Select command in code

On button Click I want to Set the Select command of a Gridview. I do this and then databind the grid but it doesn t work. What am i doing wrong? protected void bttnView_Click(object sender, ...

Hover tooltip on specific words in rich text box?

I m trying to create something like a tooltip suddenly hoovering over the mouse pointer when specific words in the richt text box is hovered over. How can this be done?

热门标签