Docusign Tabs missing only when using multiple documents - vb.net

I have a Winforms vb.net app that sends pdfs to docusign for signing. Here is my issue.
Scenario #1: pdf #1 sent alone and all tabs show as expected
Scenario #2: pdf #2 sent alone and all tabs show as expected
Scenario #3: pdf #1 & pdf #2 sent together, 4 of the 6 tabs are missing on pdf #1. The tabs missing are Initial, DateSigned and Date. Signature & FullName show as expected for pdf #1. All tabs also show correctly for pdf #2.
I am using pretty unique AnchorStrings for the missing tabs. But the Signature & FullName AnchorStrings are the same for both documents.
I am also identifying the DocumentId, RecipientId and PageNumber as required per the API Reference.
I am coming to the conclusion we will have to send each document desperately.
'Public Sub SendForSignature(ByRef Docs As List(Of DocToSign), DocSigner As Signer)
Try
If Not UserHasLogin(User.Id) Then
Throw New Exception("You do not have DocuSign credentials saved. Save your credentials in your User Settings to use DocuSign.")
End If
If Docs.Count = 0 Then
Exit Try
End If
If String.IsNullOrWhiteSpace(DocSigner.Name) Then
Throw New Exception("No recipient name found.")
End If
If String.IsNullOrWhiteSpace(DocSigner.Email) Then
Throw New Exception("No recipient email address found.")
End If
If String.IsNullOrWhiteSpace(DocSigner.RecipientId) Then
DocSigner.RecipientId = "1"
End If
If String.IsNullOrWhiteSpace(DocSigner.RoutingOrder) Then
DocSigner.RoutingOrder = "1"
End If
'Create Envelope
Dim envDef As New EnvelopeDefinition() With {
.EmailSubject = $"Signature Requested from {User.FirstName}",
.EmailBlurb = "Please sign the document. Thank you!"}
envDef.Documents = New List(Of Document)()
envDef.CustomFields = New CustomFields()
envDef.Recipients = New Recipients()
'Used for Documentid
Dim i As Integer = 1
For Each pdf As DocToSign In Docs
If Not File.Exists(pdf.Path) Then
Throw New Exception($"PDF file was not found at '{pdf.Path}'.")
End If
If Not Path.GetExtension(pdf.Path).ToLower.EndsWith("pdf") Then
Throw New Exception("File path did not end with pdf, invalid file format.")
End If
Dim filebytes As Byte() = File.ReadAllBytes(pdf.Path)
Dim lcf As New List(Of ListCustomField)
lcf.Add(New ListCustomField With {.Name = "ReferenceGUID", .Value = pdf.ReferenceGUID, .Required = "true", .Show = "false"})
lcf.Add(New ListCustomField With {.Name = "UserId", .Value = User.Id.ToString, .Required = "true", .Show = "false"})
envDef.CustomFields.ListCustomFields = lcf
'Add a document to the envelope
Dim doc As New Document()
doc.DocumentBase64 = Convert.ToBase64String(filebytes)
doc.Name = Path.GetFileName(pdf.Path)
doc.DocumentId = i.ToString()
doc.DocumentFields = New List(Of NameValue)
doc.DocumentFields.Add(New NameValue With {.Name = "ReferenceGUID", .Value = pdf.ReferenceGUID})
doc.ApplyAnchorTabs = "true"
envDef.Documents.Add(doc)
'Move Tabs per Document
Select Case pdf.DocumentTypeId
Case 2 'Client Lease
'Change for Master Leases
If pdf.IsSubLease Then
Else
SetupClientLease(DocSigner, i.ToString)
End If
Case 18 'Client NTV
SetupClientNTV(DocSigner, i.ToString)
Case 7 'Addendum
SetupClientAddendum(DocSigner, i.ToString)
Case 6 'SOP
SetupClientSOP(DocSigner, i.ToString)
Case 41 'Master Rental Agreement
Dim ECHSigner As New Signer With {.Name = User.FullName, .Email = User.EmailAddress, .RecipientId = "2", .RoutingOrder = "1"}
DocSigner.RoutingOrder = "2"
envDef.Recipients.Signers.Add(ECHSigner)
SetupMasterRentalAgreement(DocSigner, ECHSigner, i.ToString)
End Select
'Set next doc id
i += 1
Next
'Add a recipient to sign the documeent
envDef.Recipients.Signers = New List(Of Signer)()
envDef.Recipients.Signers.Add(DocSigner)
'Set envelope status to "sent" to immediately send the signature request
envDef.Status = "sent"
'Use the EnvelopesApi to send the signature request!
Dim envelopesApi As New EnvelopesApi()
Dim envelopeSummary As EnvelopeSummary = envelopesApi.CreateEnvelope(accountid, envDef)
Catch ex As Exception
Throw New Exception(ex.Message, ex.InnerException)
End Try
End Sub
Private Sub SetupClientNTV(ByRef signer As Signer, DocId As String)
Try
' Create a |SignHere| tab somewhere on the document for the recipient to sign
signer.Tabs = New Tabs()
signer.Tabs.SignHereTabs = New List(Of SignHere)
signer.Tabs.InitialHereTabs = New List(Of InitialHere)
signer.Tabs.DateTabs = New List(Of [Date])
signer.Tabs.FullNameTabs = New List(Of FullName)
signer.Tabs.DateSignedTabs = New List(Of DateSigned)
'Signature Tab
Dim signHere As New SignHere() With {
.AnchorString = "Guest Signature",
.AnchorXOffset = "2",
.AnchorYOffset = "-12",
.DocumentId = DocId,
.RecipientId = "1",
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.PageNumber = "1"}
'Full Name Tab
Dim fullName As New FullName With {
.AnchorString = "Guest Printed Name",
.AnchorXOffset = "0",
.AnchorYOffset = "-12",
.DocumentId = DocId,
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.PageNumber = "1"}
'Date Signed Tabs
Dim dateSigned As New DateSigned() With {
.AnchorString = "Date Signed",
.AnchorXOffset = "0",
.AnchorYOffset = "-12",
.DocumentId = DocId,
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.PageNumber = "1"}
'Date Tabs
Dim ntvdate As New [Date] With {
.AnchorString = "Initial ONLY ONE",
.AnchorXOffset = "292",
.AnchorYOffset = "26",
.DocumentId = DocId,
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.PageNumber = "1",
.ConditionalParentLabel = "initial1",
.ConditionalParentValue = "on",
.Width = 100}
'Initial Tabs
Dim initial1 As New InitialHere With {
.AnchorString = "Initial ONLY ONE",
.AnchorXOffset = "2",
.AnchorYOffset = "41",
.DocumentId = DocId,
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.PageNumber = "1",
.Optional = "true",
.TabLabel = "initial1",
.ScaleValue = "0.75"} 'Scale value is size - 1.0 is full size, 0.5 is 50% size
Dim initial2 As New InitialHere With {
.AnchorString = "Initial ONLY ONE",
.AnchorXOffset = "2",
.AnchorYOffset = "82",
.DocumentId = DocId,
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.PageNumber = "1",
.Optional = "true",
.TabLabel = "initail2",
.ScaleValue = "0.75"}
signer.Tabs.SignHereTabs.Add(signHere)
signer.Tabs.DateTabs.Add(ntvdate)
signer.Tabs.FullNameTabs.Add(fullName)
signer.Tabs.DateSignedTabs.Add(dateSigned)
signer.Tabs.InitialHereTabs.Add(initial1)
signer.Tabs.InitialHereTabs.Add(initial2)
Catch ex As Exception
Throw New Exception(ex.Message, ex.InnerException)
End Try
End Sub
Private Sub SetupClientSOP(ByRef signer As Signer, DocId As String)
Try
' Create a |SignHere| tab somewhere on the document for the recipient to sign
signer.Tabs = New Tabs()
signer.Tabs.SignHereTabs = New List(Of SignHere)
signer.Tabs.TextTabs = New List(Of Text)
signer.Tabs.FullNameTabs = New List(Of FullName)
signer.Tabs.DateSignedTabs = New List(Of DateSigned)
signer.Tabs.RadioGroupTabs = New List(Of RadioGroup)
Dim rg As New RadioGroup With {
.DocumentId = DocId,
.GroupName = "radios",
.RecipientId = "1",
.Radios = New List(Of Radio)}
'Signature Tab
Dim signHere As New SignHere() With {
.AnchorString = "Guest Signature",
.AnchorXOffset = "3",
.AnchorYOffset = "-11",
.DocumentId = DocId,
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.PageNumber = "1"}
'Radio Tabs
Dim radio1 As New Radio With {
.AnchorString = "Credit Card on File",
.AnchorXOffset = "-27",
.AnchorYOffset = "-3",
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.Required = "true",
.Selected = "true",
.PageNumber = "1"}
Dim radio2 As New Radio With {
.AnchorString = "Auto Debit my",
.AnchorXOffset = "-27",
.AnchorYOffset = "-3",
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.Required = "true",
.Selected = "false",
.PageNumber = "1"}
Dim radio3 As New Radio With {
.AnchorString = "Postal Mail (",
.AnchorXOffset = "-27",
.AnchorYOffset = "-3",
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.Required = "true",
.Selected = "false",
.PageNumber = "1"}
Dim radio4 As New Radio With {
.AnchorString = "Wire Transfer",
.AnchorXOffset = "-27",
.AnchorYOffset = "-3",
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.Required = "true",
.Selected = "false",
.PageNumber = "1"}
'Text Tabs (For email address - Using EmailAddress is not optional)
Dim emailHere As New Text With {
.AnchorString = "Email address where invoices should be sent:",
.AnchorXOffset = "160",
.AnchorYOffset = "-3",
.DocumentId = DocId,
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.Required = "false",
.PageNumber = "1",
.Width = 225}
'Full Name Tab
Dim fullName As New FullName With {
.AnchorString = "Guest Printed Name",
.AnchorXOffset = "0",
.AnchorYOffset = "-11",
.DocumentId = DocId,
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.AnchorIgnoreIfNotPresent = "true",
.PageNumber = "1"}
'Date Tab
Dim dateHere As New DateSigned() With {
.AnchorString = "Date:",
.AnchorXOffset = "20",
.AnchorYOffset = "-3",
.DocumentId = DocId,
.AnchorMatchWholeWord = "true",
.AnchorCaseSensitive = "true",
.PageNumber = "1"}
rg.Radios.Add(radio1)
rg.Radios.Add(radio2)
rg.Radios.Add(radio3)
rg.Radios.Add(radio4)
signer.Tabs.SignHereTabs.Add(signHere)
signer.Tabs.RadioGroupTabs.Add(rg)
signer.Tabs.TextTabs.Add(emailHere)
signer.Tabs.FullNameTabs.Add(fullName)
signer.Tabs.DateSignedTabs.Add(dateHere)
Catch ex As Exception
Throw New Exception(ex.Message, ex.InnerException)
End Try
End Sub`
Request Body
'{
"documents": [
{
"documentId": "1",
"name": "2teevgqk2dm.pdf",
"documentFields": [
{
"name": "ReferenceGUID",
"value": "2582db83-cf6e-4611-9daf-321f40a7440a"
}
],
"documentBase64": "[Base64 data omitted]",
"applyAnchorTabs": "true"
},
{
"documentId": "2",
"name": "dwwkrtmjwk3.pdf",
"documentFields": [
{
"name": "ReferenceGUID",
"value": "2582db83-cf6e-4611-9daf-321f40a7440a"
}
],
"documentBase64": "[Base64 data omitted]",
"applyAnchorTabs": "true"
}
],
"recipients": {
"signers": [
{
"tabs": {
"signHereTabs": [
{
"documentId": "2",
"pageNumber": "1",
"anchorString": "Guest Signature",
"anchorXOffset": "3",
"anchorYOffset": "-11",
"anchorIgnoreIfNotPresent": "true",
"anchorCaseSensitive": "true",
"anchorMatchWholeWord": "true"
}
],
"fullNameTabs": [
{
"documentId": "2",
"pageNumber": "1",
"anchorString": "Guest Printed Name",
"anchorXOffset": "0",
"anchorYOffset": "-11",
"anchorIgnoreIfNotPresent": "true",
"anchorCaseSensitive": "true",
"anchorMatchWholeWord": "true"
}
],
"dateSignedTabs": [
{
"documentId": "2",
"pageNumber": "1",
"anchorString": "Date:",
"anchorXOffset": "20",
"anchorYOffset": "-3",
"anchorCaseSensitive": "true",
"anchorMatchWholeWord": "true"
}
],
"textTabs": [
{
"width": 225,
"required": "false",
"documentId": "2",
"pageNumber": "1",
"anchorString": "Email address where invoices should be sent:",
"anchorXOffset": "160",
"anchorYOffset": "-3",
"anchorCaseSensitive": "true",
"anchorMatchWholeWord": "true"
}
],
"radioGroupTabs": [
{
"documentId": "2",
"recipientId": "1",
"groupName": "radios",
"radios": [
{
"pageNumber": "1",
"anchorString": "Credit Card on File",
"anchorXOffset": "-27",
"anchorYOffset": "-3",
"anchorIgnoreIfNotPresent": "true",
"anchorCaseSensitive": "true",
"anchorMatchWholeWord": "true",
"selected": "true",
"required": "true"
},
{
"pageNumber": "1",
"anchorString": "Auto Debit my",
"anchorXOffset": "-27",
"anchorYOffset": "-3",
"anchorIgnoreIfNotPresent": "true",
"anchorCaseSensitive": "true",
"anchorMatchWholeWord": "true",
"selected": "false",
"required": "true"
},
{
"pageNumber": "1",
"anchorString": "Postal Mail (",
"anchorXOffset": "-27",
"anchorYOffset": "-3",
"anchorIgnoreIfNotPresent": "true",
"anchorCaseSensitive": "true",
"anchorMatchWholeWord": "true",
"selected": "false",
"required": "true"
},
{
"pageNumber": "1",
"anchorString": "Wire Transfer",
"anchorXOffset": "-27",
"anchorYOffset": "-3",
"anchorIgnoreIfNotPresent": "true",
"anchorCaseSensitive": "true",
"anchorMatchWholeWord": "true",
"selected": "false",
"required": "true"
}
]
}
]
},
"name": "Joe Blow",
"email": "test#test.com",
"recipientId": "1",
"routingOrder": "1"
}
]
},
"customFields": {
"listCustomFields": [
{
"name": "ReferenceGUID",
"show": "false",
"required": "true",
"value": "2582db83-cf6e-4611-9daf-321f40a7440a"
},
{
"name": "UserId",
"show": "false",
"required": "true",
"value": "14"
}
]
},
"status": "sent",
"emailSubject": "Signature Requested",
"emailBlurb": "Please sign the document. Thank you!"
}'

Yes, each document gets its own id, unique for the envelope. And each anchor (autoplace) tab needs to include a documentId which specifies the document the tab belongs to.
If you have two documents and each gets a SignHere tab, then you need two different SignHere tab definitions, one for each document. It doesn't matter that the two tabs use the same anchor string text.

It appears the issue was that I was creating multiple list of tabs instead of just one list for each tab type. So only the first list was working.
I had to add the following code before I looped through to setup the tabs for each document.
DocSigner.Tabs = New Tabs()
DocSigner.Tabs.SignHereTabs = New List(Of SignHere)
DocSigner.Tabs.InitialHereTabs = New List(Of InitialHere)
DocSigner.Tabs.TextTabs = New List(Of Text)
DocSigner.Tabs.FullNameTabs = New List(Of FullName)
DocSigner.Tabs.DateSignedTabs = New List(Of DateSigned)
DocSigner.Tabs.RadioGroupTabs = New List(Of RadioGroup)
DocSigner.Tabs.TitleTabs = New List(Of Title)
DocSigner.Tabs.DateTabs = New List(Of [Date])

Related

Populate Datagridview price chart

I want to populate my DataGridView (dgvMain) with Bitcoin price I get using webrequest API.
The Price example response from request: 36.560 should be populated in the row1 and 4th column (column(3))
My Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = False
getPriceBTC()
InitializeDataGridView()
End Sub
Private Sub InitializeDataGridView()
' Set the column header style.
Dim columnHeaderStyle As New DataGridViewCellStyle()
'columnHeaderStyle.BackColor = Color.Beige
columnHeaderStyle.Font = New Font("arial", 10, FontStyle.Bold)
dgvMain.ColumnHeadersDefaultCellStyle = columnHeaderStyle
' Set the column header names.
dgvMain.ColumnCount = 11
dgvMain.Columns(0).Name = "#"
dgvMain.Columns(0).Width = 50
dgvMain.Columns(1).Name = "ID"
dgvMain.Columns(2).Name = "Coin"
dgvMain.Columns(3).Name = "Price (EUR)"
dgvMain.Columns(4).Name = "Last 1h"
dgvMain.Columns(5).Name = "Last 24h"
dgvMain.Columns(6).Name = "Last 7d"
dgvMain.Columns(7).Name = "24h Volume"
dgvMain.Columns(8).Name = "M. Capital"
dgvMain.Columns(9).Name = "If Higher"
dgvMain.Columns(10).Name = "If Lower"
' Populate the rows.
Dim row1() As String = {"", "BTC", "BitCoin", "", "", " ", "", "", "", "", ""}
Dim row2() As String = {"", "ETH", "Ethereum", "", "", "", "", "", "", "", ""}
Dim row3() As String = {"", "ADA", "Cardano", "", "", "", "", "", "", "", ""}
Dim row4() As String = {"", "GLMR", "Moonbeam", "", "", "", "", "", "", "", ""}
Dim row5() As String = {"", "ELON", "Dogelon Mars", "", "", "", "", "", "", "", ""}
Dim row6() As String = {"", "MBOX", "Mobox", "", "", "", "", "", "", "", ""}
Dim row7() As String = {"", "BLOK", "Bloktopia", "", "", "", "", "", "", "", ""}
Dim row8() As String = {"", "STARL", "Starlink", "", "", "", "", "", "", "", ""}
Dim row9() As String = {"", "OOKI", "Ooki Protocol", "", "", "", "", "", "", "", ""}
Dim row10() As String = {"", "Floki", "Floki Inu", "", "", "", "", "", "", "", ""}
Dim row11() As String = {"", "EGC", "EverGrow Coin", "", "", "", "", "", "", "", ""}
Dim row12() As String = {"", "SQUID", "Squid Game", "", "", "", "", "", "", "", ""}
Dim row13() As String = {"", "HOT", "Holo", "", "", "", "", "", "", "", ""}
Dim row14() As String = {"", "ATLAS", "Star Atlas", "", "", "", "", "", "", "", ""}
Dim row15() As String = {"", "ZODI", "Zodium", "", "", "", "", "", "", "", ""}
Dim row16() As String = {"", "VML", "Meta Land", "", "", "", "", "", "", "", ""}
Dim row17() As String = {"", "SNN", "SeChain", "", "", "", "", "", "", "", ""}
Dim rows() As Object = {row1, row2, row3, row4, row5, row6, row7, row8, row9, row10, row11, row12, row13, row14, row15, row16, row17}
Dim rowArray As String()
For Each rowArray In rows
dgvMain.Rows.Add(rowArray)
Next rowArray
Dim chk As New DataGridViewCheckBoxColumn()
dgvMain.Columns.Add(chk)
chk.HeaderText = "Enable"
chk.Name = "chk"
chk.Width = 70
End Sub
Public Sub getPriceBTC()
Try
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
ServicePointManager.Expect100Continue = True
'Dim _price As String = txtCryptoPrice.Text
Dim _url As String = "https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=EUR"
Dim _req As System.Net.HttpWebRequest = System.Net.HttpWebRequest.Create(_url)
_req.Proxy = Nothing
_req.UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.81 Safari/537.36"
Dim _resp As System.Net.HttpWebResponse = _req.GetResponse
Dim streamReader As System.IO.StreamReader = New System.IO.StreamReader(_resp.GetResponseStream())
Dim API_source As String = streamReader.ReadToEnd
Dim _Fprice = API_source.ToLower.ToString
Dim _priceF = _Fprice.Substring(7)
Dim jsonprice As String = _priceF.Replace("}", "")
Dim row As DataGridViewRow = Nothing
For Each item As DataGridViewRow In dgvMain.Rows
row = item
row.Cells(3).Value = jsonprice
Next
_runningThreads.Remove(Thread.CurrentThread)
Catch ex As Exception
End Try
End Sub
I added piece of CODE after I edited but it shows now in all CELLS
the btc price so how DO I add it only to the first row?
row.Cells(3).Value = jsonprice
heheheh I google it :p
dgvMain.Rows(0).Cells(3).Value = jsonprice
yeees!

How to add Name field in Docusing envelope?

Currently i can create envelope with signers dynamically, now i want to add Name field above the signer, i using below code to set Auto search Text.
' Document
Dim doc1 As Document = New Document With {
.DocumentBase64 = doc1DocxBytes,
.Name = ext1(0),
.FileExtension = ext1(1),
.DocumentId = "1"
}
env.Documents = New List(Of Document) From {
doc1
}
'Signer1
Dim signer1 As Signer = New Signer With {
.Email = signerEmail,
.Name = signerName,
.RecipientId = "1",
.RoutingOrder = "1"
}
Dim signHere212 As SignHere = New SignHere With {
.AnchorString = "For and on behalf of the vendor",
.AnchorUnits = "pixels",
.AnchorYOffset = "70",
.AnchorXOffset = "20"
}
Dim fullName212 As FullName = New FullName With {
.AnchorString = "For and on behalf of the vendor",
.AnchorUnits = "pixels",
.AnchorYOffset = "100",
.AnchorXOffset = "20"
}
Dim signer1Tabs As Tabs = New Tabs With {
.SignHereTabs = New List(Of SignHere) From {
signHere212
},
.FullNameTabs = New List(Of FullName) From {
fullName212
}
}
signer1.Tabs = signer1Tabs
Dim recipients As Recipients = New Recipients With {
.Signers = New List(Of Signer) From {
signer1
}
}
env.Recipients = recipients
env.Status = "sent"
Dim envelopeEvents = New List(Of EnvelopeEvent)()
envelopeEvents.Add(New EnvelopeEvent With {
.EnvelopeEventStatusCode = "completed",
.IncludeDocuments = "true"
})
eventNotification.EnvelopeEvents = envelope
From above code i placed sign on the top of "For and on behalf of the vendor", now i want Name field to add Name when signer sign the document.Please provide piece of code.
Dim fullName212 As FullName = New FullName With {
.AnchorString = "For and on behalf of the vendor",
.AnchorUnits = "pixels",
.AnchorYOffset = "70",
.AnchorXOffset = "20"
}
Dim signer1Tabs As Tabs = New Tabs With {
.SignHereTabs = New List(Of SignHere) From {
signHere1
},
.FullNameTabs = New List(Of FullName) From {
fullName212
}
signer1.Tabs = signer1Tabs
Dim recipients As Recipients = New Recipients With {
.Signers = New List(Of Signer) From {
signer1
}
}

Retrieve String Join separated by a comma

Output Expected: I want to return the combinations of 2, in the case below, each separated by a comma and vbcrlf, for example:
1,2
3,4
5,6
and so on...
the problem is that this code below does not.
It returns my values in the line (1,2,3,4,5,6,7,8,9,10,11,12 .. and so on.
how do I make the code from button1 work properly?
Function GetCombinations(ByVal depth As Integer, ByVal values As String()) As IEnumerable(Of String)
If depth > values.Count + 1 Then Return New List(Of String)
Dim result = New List(Of String)
For i = 0 To depth - 1
For y = 0 To values.Count - 1
If i = 0 Then
result.Add(values(y))
Else
result.Add(values(i - 1) + values(y))
End If
Next
Next
Return result
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim data_array As String() = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
"15"}
Dim result = GetCombinations(2, data_array)
Dim resultx As String = String.Join(",", result)
TxtListScanTxt.AppendText(resultx)
End Sub
This is one way to do it - tested and working
Public Sub Main()
Dim data_array As String() = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
"15"}
dim second as boolean
dim sb = new stringbuilder()
For i as integer = 0 To data_array.Length - 1
if second then
sb.AppendLine(data_array(i -1) & "," & data_array(i))
second = false
continue for
end if
if i = data_array.Length - 1 then
sb.AppendLine(data_array(i))
end if
second = true
next
Console.WriteLine(sb.ToString())
End Sub
my solution
Dim data_array As String() = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14",
"15"}
Dim depth As Integer = 3, i As Integer = 1
Dim result As StringBuilder = New StringBuilder
For y = 0 To data_array.Count - 1
If i < depth Then
result.Append(data_array(y) + ",")
i += 1
Else
result.Append(data_array(y) + vbNewLine)
i = 1
End If
Next
RichTextBox1.AppendText(result.ToString)
Sub Main(args As String())
Dim arr = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"}
'// First, we join all array values with comma to get a string.
'// Second, we find each group of two digits separated by comma (\d+,\d+)
'// and replace it ($1) with the same group PLUS the new-line character.
Dim x = Regex.Replace(String.Join(",", arr), "(\d+,\d+),?", $"$1{vbCrLf}")
End Sub

Caesar Cipher encryption VB.net

I am trying to make an encryption method in VB.net.
I plan to use arrays so you input the value and it then compares two arrays changing the value.
Console.WriteLine("Please input text")
Dim UserInput As String = Console.ReadLine
UserInput = UserInput.ToUpper()
Console.WriteLine("Original Input is " & UserInput)
Dim EncriptedText As String
Dim Numbers() As String = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "21", "22", "23", "24", "25", "26", "27"}
Dim Letters() As String = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " "}
For counter As Integer = 0 To UserInput.Length - 1
Dim pos As Integer = Array.IndexOf(Numbers, UserInput.Chars(counter))
Dim CharValue As Char = Letters.ElementAt(pos)
UserInput = UserInput + CharValue
Console.WriteLine(UserInput)
Next
Console.Read()
End Sub
It throws an error when I try to run it.
Does anyone have any idea how I could fix it?
Error : Found on The Dim CharValue As Char Line
An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in mscorlib.dll
Additional information: Index was out of range. Must be non-negative and less than the size of the collection.
I was thinking it could be because I am trying to convert numbers to chars and if so what other methods could I use?
1) You are using the wrong array to get the index of a letter, and so the wrong array to get its enciphered value.
2) When you use Array.IndexOf like that, you need to give it a string to look for rather than a char. In your code, it is returning -1 because it didn't find the char in the array of strings (once the correct array is used).
3) You're modifying the input string in the loop, I guess you meant to use a separate variable for it.
Console.WriteLine("Please input text")
Dim userInput As String = Console.ReadLine()
userInput = userInput.ToUpper()
Console.WriteLine("Original input is " & userInput)
Dim numbers() As String = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "21", "22", "23", "24", "25", "26", "27"}
Dim letters() As String = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " "}
Dim encryptedText As String = ""
For counter As Integer = 0 To userInput.Length - 1
Dim pos As Integer = Array.IndexOf(letters, (userInput.Chars(counter)))
Dim cipherValue As String = numbers.ElementAt(pos)
encryptedText = encryptedText & cipherValue
Console.WriteLine(encryptedText)
Next
Console.Read()
Please note that it is usual to start variable names with a lowercase letter.
Now that you can get output, you can go on to find the other problems with the code :)

VB2010 Mutli-dimensional Arrays, mind-block

So I am trying to make the card game WAR in visual basic 2010. I have the following code and I kind of know what I need to do next but I just can't get to the next step.
Public Class form1
'throws an error unless this is the first class in the file
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'click the button currently labled "loop"
Dim Cards() As String = {"Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack"} 'spades,hearts/diamonds,clubs
Dim Values() As String = {"11", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11"} 'faces is a term meaning a card that depicts a person
Dim suits() As String = {"H", "D", "C", "S"}
Dim p1deck()() As String '
'first (0) is the number of the array
'second(0) is the string
p1deck(0)(0) = "Ace"
p1deck(0)(1) = "11"
p1deck(0)(2) = "Hearts"
TextBox1.Text = p1deck(0)(0) & " of " & p1deck(0)(2)
'Cards.ToList(). add/removeAt
End Sub
End Class
You are not Initializing your p1deck array.
Try something like this:
Dim p1deck(2, 3) As String
p1deck(0, 0) = "Ace"
p1deck(0, 1) = "11"
p1deck(0, 2) = "Hearts"
TextBox1.Text = p1deck(0, 0) & " of " & p1deck(0, 2)