VB.net将Array 1的值传递给Array 2

时间:2016-02-05 16:41:35

标签: arrays vb.net encryption modulo

所以我有这个代码,我需要将array1的值传递给array2, 但是array2的值应该是array1 +(key Mod 255),其中key由用户放置

    Private Sub mod_Btn_enc_Click(sender As Object, e As EventArgs) Handles mod_Btn_enc.Click
    Dim counter As Integer = 0
    If mod_TB_key.Text = "" Then
        MessageBox.Show("Pls Input Modulo Key Value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
    Else
        modKey = mod_TB_key.Text
    End If

    modModulo = modKey Mod 255 'formula
    mod_TB_mod.Text = modModulo 'i used this to show that it is working
'modbyte = array 1
'modconverted = array2
    For Each i As Integer In modByte
        counter += 1
        modConverted(counter - 1) = modByte(i - 1) + (modModulo) 'formula used
    Next i
    mod_Tb_enc.Text = String.Join(" ", modConverted) 'show the array in textbox

这是我的界面

enter image description here

1 个答案:

答案 0 :(得分:0)

我设法这样做了。

For i = 0 To modByte.GetUpperBound(0)
        counter += 1
        ReDim Preserve modConverted(counter - 1)
        modConverted(counter - 1) = modByte(i) + (modModulo)
    Next

感谢您解释@phoog