Split first <br> from sentence using vb - vb.net

I have the one sentence Eric Corni<br>chargé de clientèle<br>Tél: 09 99 99 99 99 72<br> atricard#adiscos.com I want to get only chargé de clientèle<br>Tél: 09 99 99 99 99 72<br> atricard#adiscos.com
I have the code as below:
strText = Replace(strText, "_com_position_", Right(com_signature,InStrRev(com_signature, ">", len(com_signature))+3))
And _com_position_ = "Eric Corni<br>chargé de clientèle<br>Tél: 09 99 99 99 99 72<br> atricard#adiscos.com" but it displays wrong with what I need.it displays like this: gé de clientèle<br>Tél: 09 99 99 99 99 72<br> atricard#adiscos.com
Do you have any solution, please help me to fix it, Thanks.

Use instr function() .. and known that length of <br> is 4 then
Dim strText As String = "Eric Corni<br>chargé de clientèle<br>Tél: 09 99 99 99 99 72<br> atricard#adiscos.com"
strText = Mid(strText,InStr(strText, "<br>") + 4)

Try this:
strText = strText.SubString(strText.IndexOf("<br>") + 4)

One possible solution (using vbscript) would be to remove the first part of the string with a regular expression:
strText = "Eric Corni<br>chargé de ..."
Set re = New RegExp
re.Pattern = "^.*?<br>"
re.IgnoreCase = True
WScript.Echo re.Replace(strText, "")

Related

Reverse Number in VB.Net

I want Reverse Number: example:
Textbox1.Text = 2 14 21 22 34 44
a deployment algorithm to do this. make
Expected Output: All Combination possible Reverse.
2 41 21 22 34 44
2 14 12 22 34 44
2 14 21 22 43 44
2 14 21 22 34 44
2 41 12 22 34 44
2 41 12 22 43 44
and so on...
2 14 21 22 34 44
What I try: it works, but it does not carry all the possible combinations, as in the above model.
Dim r As Integer
Public Function Reverse(rn As Integer)
Dim value As Integer
Dim values As New List(Of String)
For Each strValue As String In TextBox1.Text.Split(" ".ToCharArray, StringSplitOptions.RemoveEmptyEntries)
If Integer.TryParse(strValue.Trim, value) Then
values.Add(value)
End If
Next
Dim numbers = Val(TextBox1.Text)
Dim result As Integer
While numbers > 0
rn = numbers Mod 10
result = result * 10 + rn
numbers = numbers \ 10
End While
Reverse = result
End Function
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
TextBox2.Text = Reverse(r & " ")
End Sub

Loop through all cells in a table from Outlook email

I have a standardized email that is sent to me that contains a table (11R x 3C) of which I only require the information from a couple of specific cells.
The table format from the email as follows.
1 |<Empty> |<Empty> |<Empty> |
2 | <Useless info> |
3 | <Impt Info> |
4 |Name: |NameID |<Empty> |
5 |Email: |EmailID |<Empty> |
6 |Contact: |ContactID|<Empty> |
7 |Comment: |CommentID|<Empty> |
8 | <Useless Info> |
9 | <Useless Info> |
10 | <Useless Info> |
11 | <Useless Info> |
Of the table, I am only interested in values of <Impt Info>, NameID, EmailID, ContactID and CommentID.
I've tried looping through the table using debug.print as a Word table object but for some reason it sees the entire table as a single cell. Could I be assigning the table object wrongly or simply using the wrong codes?
Below is the code I've tried to use:
Sub test()
Dim objMail As Outlook.MailItem
Dim objWordDocument As Word.Document
Dim objTable As Word.Table
Dim objExcelApp As Excel.Application
Dim objExcelWorkbook As Excel.Workbook
Dim objExcelWorksheet As Excel.Worksheet
Dim I As Long
Dim SavePath As String
Dim SaveName As String
'Create a new excel workbook
Set objExcelApp = CreateObject("Excel.Application")
Set objExcelWorkbook = objExcelApp.Workbooks.Add
objExcelApp.Visible = True
'Get the table(s) in the selected email
Set objMail = Outlook.Application.ActiveExplorer.Selection.item(1)
Set objWordDocument = objMail.GetInspector.WordEditor
SavePath = "C:\Users\John.Grammaticus\Desktop\Test\"
SaveName = objMail.SenderName & " " & objMail.Subject
Set objTable = objWordDocument.Tables(1)
For Each C In objTable.Range.Cells
Debug.Print C.Range.Text
Next C
objTable.Range.Copy
Set objExcelWorksheet = objExcelWorkbook.Sheets(1)
objExcelWorksheet.Paste
objExcelWorkbook.SaveAs FileName:=SavePath & " " & SaveName
objExcelWorkbook.Close
End Sub
The current code exports the values into an Excel and I could potentially just manipulate from Excel instead. However, I would like to eventually pump the info directly into an Access DB. Hence the need to draw out specific values.
Try using InStr function MSDN
Example
Option Explicit
Public Sub Example()
Dim Item As Outlook.MailItem
Dim vText As Variant
Dim sText As String
Dim vItem As Variant
Dim i As Long
If Application.ActiveExplorer.selection.Count = 0 Then
MsgBox "No Item selected!", vbCritical, "Error"
End If
For Each Item In Application.ActiveExplorer.selection
sText = Item.Body ' Email Body
vText = Split(sText, Chr(13)) ' Chr(13) = Carriage return
'// Check each line of text in the message body down loop
For i = UBound(vText) To 0 Step -1
'// InStr([start,]mainString, SearchedString[, compare])
If InStr(1, vText(i), "Name:") > 0 Then
'// Split vItem : & :
vItem = Split(vText(i), Chr(58)) ' Chr(58) = :
Debug.Print Trim(vItem(1)) 'Print on Immediate Window
End If
Next
Next
End Sub
Or use horizontal tab Chr(9)
See Character Chart
'Dec|Hex|Oct| Char | Description
'-------------------------------
'0 0 000 null
'1 1 001 start of heading
'2 2 002 start of text
'3 3 003 end of text
'4 4 004 end of transmission
'5 5 005 enquiry
'6 6 006 acknowledge
'7 7 007 bell
'8 8 010 backspace
'9 9 011 horizontal tab
'10 A 012 new line
'11 B 013 vertical tab
'12 C 014 new page
'13 D 015 carriage return
'14 E 016 shift out
'15 F 017 shift in
'16 10 020 data link escape
'17 11 021 device control 1
'18 12 022 device control 2
'19 13 023 device control 3
'20 14 024 device control 4
'21 15 025 negative acknowledge
'22 16 026 synchronous idle
'23 17 027 end of trans. block
'24 18 030 cancel
'25 19 031 end of medium
'26 1A 032 substitute
'27 1B 033 escape
'28 1C 034 file separator
'29 1D 035 group separator
'30 1E 036 record separator
'31 1F 037 unit separator
'32 20 040 space
'33 21 041 !
'34 22 042 "
'35 23 043 #
'36 24 044 $
'37 25 045 %
'38 26 046 &
'39 27 047 '
'40 28 050 (
'41 29 051 )
'42 2A 052 *
'43 2B 053 +
'44 2C 054 ,
'45 2D 055 -
'46 2E 056 .
'47 2F 057 /
'48 30 060 0
'49 31 061 1
'50 32 062 2
'51 33 063 3
'52 34 064 4
'53 35 065 5
'54 36 066 6
'55 37 067 7
'56 38 070 8
'57 39 071 9
'58 3A 072 :
'59 3B 073 ;
'60 3C 074 <
'61 3D 075 =
'62 3E 076 >
'63 3F 077 ?
'64 40 100 #
'65 41 101 A
'66 42 102 B
'67 43 103 C
'68 44 104 D
'69 45 105 E
'70 46 106 F
'71 47 107 G
'72 48 110 H
'73 49 111 I
'74 4A 112 J
'75 4B 113 K
'76 4C 114 L
'77 4D 115 M
'78 4E 116 N
'79 4F 117 O
'80 50 120 P
'81 51 121 Q
'82 52 122 R
'83 53 123 S
'84 54 124 T
'85 55 125 U
'86 56 126 V
'87 57 127 W
'88 58 130 X
'89 59 131 Y
'90 5A 132 Z
'91 5B 133 [
'92 5C 134 \
'93 5D 135 ]
'94 5E 136 ^
'95 5F 137 _
'96 60 140 `
'97 61 141 a
'98 62 142 b
'99 63 143 c
'100 64 144 d
'101 65 145 e
'102 66 146 f
'103 67 147 g
'104 68 150 h
'105 69 151 i
'106 6A 152 j
'107 6B 153 k
'108 6C 154 l
'109 6D 155 m
'110 6E 156 n
'111 6F 157 o
'112 70 160 p
'113 71 161 q
'114 72 162 r
'115 73 163 s
'116 74 164 t
'117 75 165 u
'118 76 166 v
'119 77 167 w
'120 78 170 x
'121 79 171 y
'122 7A 172 z
'123 7B 173 {
'124 7C 174 |
'125 7D 175 }
'126 7E 176 ~
'127 7F 177 DEL

Convert big string to decimal in vb.net

Hello i have big string value which is md5 of something now i need to convert it into the decimal value
for example
Dim md5_s As String = "6F05AF42533432A5513610FE839ACC86"
now i need output same like the online converters to this
"54 70 48 53 65 70 52 50 53 51 51 52 51 50 65 53 53 49 51 54 49 48 70
69 56 51 57 65 67 67 56 54 "
is it possible i don't want spaces in the above converted decimal ?
vb.net help please
Okay here i tried and got it n is my approach works fine will this fine n work always right
Dim t As String
Dim a As String = "6F05AF42533432A5513610FE839ACC86"
For Each c As Char In a
t &= Convert.ToInt32(c)
Next
TextBox1.Text = t
will this one is right ?
result is same what i am looking for as
5470485365705250535151525150655353495154494870695651576567675654
so i assume this is right huh ?
I'm not quite sure this is what you are really looking for but this is what you asked for
For count = 0 To md5_s.Length - 1
Dim tempChar As String = md5_s.Substring(count, 1)
Console.Write(Asc(tempChar))
Next
What is more likely what you want is something like this
Private Function HexToByteArray(ByVal hex As [String]) As Byte()
Dim NumberChars As Integer = hex.Length
Dim bytes As Byte() = New Byte(NumberChars / 2 - 1) {}
For i As Integer = 0 To NumberChars - 1 Step 2
bytes(i / 2) = Convert.ToByte(hex.Substring(i, 2), 16)
Next
Return bytes
End Function
either way ... hope this helps

copy sets of numbers into a listbox from a textbox

I have a textbox that the user puts in sets of numbers(e.g. 32 45 98 56 52 1 23) and I need to copy these numbers into a listbox so that each number is its own item. So far I have this
For Each ch As Char In TextBox20.Text
If Char.IsDigit(ch) Then
ListBox1.Items.Add(ch)
End If
Next
but the problem is that it will copy each digit as an item so we will end up with
3
2
4
5
9
8
5
6
I need it to copy them like this
32
45
98
56
here is a sample of how to do that
Sub addToListBox()
Dim sample As String
Dim v As Variant
Dim i As Integer
sample = "32 45 98 56 52 1 23"
v = Split(sample, " ")
For i = 0 To UBound(v)
If IsNumeric(v(i)) Then
ListBox1.Items.Add(v(i))
End If
Next i
End Sub

Simple rot13 encoder in vb.net

I am looking for a simple way to encode an inputted text into Rot13. I am hitting a brick wall at the stage of being able to separate out words into individual characters and integers so that I can change each one and output the result. I can do it with single letters using a simple if statement listed bellow but if anyone can help with a way of doing it for whole words I would be very appreciative.
If kInput = "a" then kOutput = "n"
Thanks, Kai
Looks like people are giving good answers to this but here's my try at it.
Dim input As String = "This is a Test!! Guvf vf n Grfg!!"
Dim result As StringBuilder = New StringBuilder()
For Each ch As Char In input
If (Not Char.IsLetter(ch)) Then
result.Append(ch)
Continue For
End If
Dim checkIndex As Integer = Asc("a") - (Char.IsUpper(ch) * -32)
Dim index As Integer = ((Asc(ch) - checkIndex) + 13) Mod 26
result.Append(Chr(index + checkIndex))
Next
Console.WriteLine(result.ToString())
EDIT: improved to remove need for uppercase check. This will properly handle case and special characters with only 1 if statement inside the loop.
It seems like you're making this way harder than it has to be. No need to separate words, etc, and definitely no need for a large If/Else block:
Public Function Rot13(ByVal input As String) As String
Dim result As Char() = input.ToCharArray()
For i As Integer = 0 To result.Length - 1
Dim temp As Integer = Asc(result(i))
Select Case temp
Case 65 to 77, 97 To 109 'A - M
result(i) = Chr(temp + 13)
Case 78 to 90, 110 To 122 'N - Z
result(i) = Chr(temp - 13)
End Select
Next i
Return New String(result)
End Function
Note that this was entered directly into the browser window and is completely untested.
Just call it once to encode, call it again to decode.
Private Function ROT13_Encode(ByVal Input As String) As String
Dim chrs As Char() = Input.ToCharArray()
Dim ReturnString As String = ""
Dim CharInt As Integer
For Each Chr As Char In chrs
CharInt = Asc(Chr)
If CharInt >= 65 And CharInt <= 77 Then 'A-M
CharInt += 13
ElseIf CharInt >= 78 And CharInt <= 90 Then 'M-Z
CharInt -= 13
ElseIf CharInt >= 97 And CharInt <= 109 Then 'a-m
CharInt += 13
ElseIf CharInt >= 110 And CharInt <= 122 Then 'm-z
CharInt -= 13
End If
ReturnString &= ChrW(CharInt)
Next
Return ReturnString
End Function