How to get the value without encoding in vb.net watch? - vb.net

In vb.net in debugging you can watch a variable and right click.
There are options between copy and copy value.
There is little differences. I basically got this
"[" & vbCrLf & " {" & vbCrLf & " ""id"": 22812485751," & vbCrLf & " ""currencyPair"": ""ORME/BTC""," & vbCrLf & " ""goodUntilTime"": 0," & vbCrLf & " ""type"": ""LIMIT_SELL""," & vbCrLf & " ""orderStatus"": ""EXECUTED""," & vbCrLf & " ""issueTime"": 1539721209920," & vbCrLf & " ""price"": 2.726E-05," & vbCrLf & " ""quantity"": 1733.83246147," & vbCrLf & " ""remainingQuantity"": 0.0," & vbCrLf & " ""commissionByTrade"": 8.508E-05," & vbCrLf & " ""bonusByTrade"": 0," & vbCrLf & " ""bonusRate"": 0," & vbCrLf & " ""commissionRate"": 0.0018," & vbCrLf & " ""lastModificationTime"": 1539727280096" & vbCrLf & " }," & vbCrLf & " {" & vbCrLf & " ""id"": 19661583751," & vbCrLf & " ""currencyPair"": ""ORME/ETH""," & vbCrLf & " ""goodUntilTime"": 0," & vbCrLf & " ""type"": ""LIMIT_BUY""," & vbCrLf & " ""orderStatus"": ""EXECUTED""," & vbCrLf & " ""issueTime"": 1537113087231," & vbCrLf & " ""price"": 0.00110001," & vbCrLf & " ""quantity"": 1733.83246562," & vbCrLf & " ""remainingQuantity"": 0.0," & vbCrLf & " ""commissionByTrade"": 0.003433," & vbCrLf & " ""bonusByTrade"": 0," & vbCrLf & " ""bonusRate"": 0," & vbCrLf & " ""commissionRate"": 0.0018," & vbCrLf & " ""lastModificationTime"": 1538092923124" & vbCrLf & " }," & vbCrLf & " {" & vbCrLf & " ""id"": 19669018551," & vbCrLf & " ""currencyPair"": ""ORME/BTC""," & vbCrLf & " ""goodUntilTime"": 0," & vbCrLf & " ""type"": ""LIMIT_SELL""," & vbCrLf & " ""orderStatus"": ""EXECUTED""," & vbCrLf & " ""issueTime"": 1537118640003," & vbCrLf & " ""price"": 4.302E-05," & vbCrLf & " ""quantity"": 1140.08057366," & vbCrLf & " ""remainingQuantity"": 0.0," & vbCrLf & " ""commissionByTrade"": 8.829E-05," & vbCrLf & " ""bonusByTrade"": 0," & vbCrLf & " ""bonusRate"": 0," & vbCrLf & " ""commissionRate"": 0.0018," & vbCrLf & " ""lastModificationTime"": 1537119048771" & vbCrLf & " }," & vbCrLf & " {" & vbCrLf & " ""id"": 19666104251," & vbCrLf & " ""currencyPair"": ""ORME/BTC""," & vbCrLf & " ""goodUntilTime"": 0," & vbCrLf & " ""type"": ""LIMIT_SELL""," & vbCrLf & " ""orderStatus"": ""PARTIALLY_FILLED_AND_CANCELLED""," & vbCrLf & " ""issueTime"": 1537116476248," & vbCrLf & " ""price"": 4.25E-05," & vbCrLf & " ""quantity"": 7487.1," & vbCrLf & " ""remainingQuantity"": 1140.08057366," & vbCrLf & " ""commissionByTrade"": 0.00048563," & vbCrLf & " ""bonusByTrade"": 0," & vbCrLf & " ""bonusRate"": 0," & vbCrLf & " ""commissionRate"": 0.0018," & vbCrLf & " ""lastModificationTime"": 1537116507585" & vbCrLf & " }," & vbCrLf & " {" & vbCrLf & " ""id"": 19661490851," & vbCrLf & " ""currencyPair"": ""ETH/BTC""," & vbCrLf & " ""goodUntilTime"": 0," & vbCrLf & " ""type"": ""LIMIT_BUY""," & vbCrLf & " ""orderStatus"": ""EXECUTED""," & vbCrLf & " ""issueTime"": 1537113025233," & vbCrLf & " ""price"": 0.03357901," & vbCrLf & " ""quantity"": 1.91066607," & vbCrLf & " ""remainingQuantity"": 0.0," & vbCrLf & " ""commissionByTrade"": 0.00011548," & vbCrLf & " ""bonusByTrade"": 0," & vbCrLf & " ""bonusRate"": 0," & vbCrLf & " ""commissionRate"": 0.0018," & vbCrLf & " ""lastModificationTime"": 1537113028429" & vbCrLf & " }," & vbCrLf & " {" & vbCrLf & " ""id"": 17637942051," & vbCrLf & " ""currencyPair"": ""ORME/BTC""," & vbCrLf & " ""goodUntilTime"": 0," & vbCrLf & " ""type"": ""LIMIT_SELL""," & vbCrLf & " ""orderStatus"": ""EXECUTED""," & vbCrLf & " ""issueTime"": 1535545801765," & vbCrLf & " ""price"": 4.5E-05," & vbCrLf & " ""quantity"": 2289.92000001," & vbCrLf & " ""remainingQuantity"": 0.0," & vbCrLf & " ""commissionByTrade"": 0.00018916," & vbCrLf & " ""bonusByTrade"": 0," & vbCrLf & " ""bonusRate"": 0," & vbCrLf & " ""commissionRate"": 0.0018," & vbCrLf & " ""lastModificationTime"": 1535545801765" & vbCrLf & " }," & vbCrLf & " {" & vbCrLf & " ""id"": 17637532551," & vbCrLf & " ""currencyPair"": ""ORME/BTC""," & vbCrLf & " ""goodUntilTime"": 0," & vbCrLf & " ""type"": ""LIMIT_SELL""," & vbCrLf & " ""orderStatus"": ""PARTIALLY_FILLED_AND_CANCELLED""," & vbCrLf & " ""issueTime"": 1535545474694," & vbCrLf & " ""price"": 4.78E-05," & vbCrLf & " ""quantity"": 2487.1," & vbCrLf & " ""remainingQuantity"": 2289.92000001," & vbCrLf & " ""commissionByTrade"": 1.697E-05," & vbCrLf & " ""bonusByTrade"": 0," & vbCrLf & " ""bonusRate"": 0," & vbCrLf & " ""commissionRate"": 0.0018," & vbCrLf & " ""lastModificationTime"": 1535545515636" & vbCrLf & " }" & vbCrLf & "]"
And that sucks and hard to read. If a string contains a json, I want to see the json as it actually is. I want to be able to copy that to notepad.
How do I do so?

Here is what you can do when debugging.
put mouse over your variable. Popup menu will show up and there you will see magnifying lens
click that
Right-click on your variable, select "Quick Watch" in the menu a screen will show
click magnifying lens

Related

SVG to display on button click event but how?

I have a textbox with some SVG code written in it and I would like to display it as my actual html page in a WebBrowser once the button click event is triggerd but I can see how to do that.
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Text = "<!DOCTYPE html><html><body><svg height=" & Chr(34) & "5000" & Chr(34) & " width=" & Chr(34) & "5000" & Chr(34) & "><g style=" & Chr(34) & "fill:none;stroke:rgb(255,0,0);stroke-width:0.1" & Chr(34) & " stroke-dasharray=" & Chr(34) & "40,5,10,5" & Chr(34) & "><line x1=" & Chr(34) & "0" & Chr(34) & " y1=" & Chr(34) & "0" & Chr(34) & " x2=" & Chr(34) & "200" & Chr(34) & " y2=" & Chr(34) & "150" & Chr(34) & "/><line x1=" & Chr(34) & "200" & Chr(34) & " y1=" & Chr(34) & "150" & Chr(34) & " x2=" & Chr(34) & "400" & Chr(34) & " y2=" & Chr(34) & "0" & Chr(34) & "/><polyline points=" & Chr(34) & "0,0 50,50 0,100 50,100 130,150 210,190" & Chr(34) & "/></g></svg></body></html>"
WebBrowser1.Document.Write(TextBox1.Text)
End Sub

Reading Code From a Text File Efficiently And How to Distinguish Blocks of Code In The Text File

I'm creating a utility for a game that creates spreadsheets of data by reading the game's code.
One of the most basic aspects of this is being able to read the game's code efficiently. The game is written in C#. I'm using VB.Net for my program because my mind can't grasp the abstraction of more complex languages. Historically the way I had my program recognise code blocks in the code text file is by counting the brackets that encapsulated them and working off of that. This seems a bit clunky, though. Is there any simpler way to help the program figure out code blocks?
For Example, code in the text file might look like this:
6673={
key="d_example_duchy_1"
de_facto_liege=12
variables={
data={ {
flag="traditional_de_jure_kingdom"
tick=0
data={
type=lt
identity=6632
}
}
}
}
de_jure_liege=6632
de_jure_vassals={ 6674 6678 6682 6686 }
holder=558
name="Example Duchy 1"
date=1253.1.1
heir={ 880 }
history={ 1253.1.1=558 }
capital=6674
history_government="tribal_government"
coat_of_arms_id=2320
}
6674={
key="c_example_county_1"
variables={
data={ {
flag="influx_culture"
tick=0
data={
type=culture
identity=11
}
}
{
flag="influx_faith"
tick=0
data={
type=faith
identity=57
}
}
{
flag="fog_resistance"
tick=0
data={
type=value
}
}
}
}
de_jure_liege=6673
de_jure_vassals={ 6675 6676 6677 }
holder=558
name="Example County 1"
date=1243.6.26
heir={ 880 }
capital=6674
coat_of_arms_id=2323
}
6675={
key="b_example_barony_1"
de_facto_liege=6674
de_jure_liege=6674
holder=558
name="Example Barony 1"
date=1254.1.1
capital_barony=yes
duchy_capital_barony=yes
capital=6674
coat_of_arms_id=2328
}
6676={
key="b_example_barony_2"
de_facto_liege=6674
de_jure_liege=6674
holder=11609
name="Example Barony 2"
date=1253.7.28
capital=6674
coat_of_arms_id=2332
}
6677={
key="b_example_barony_3"
de_facto_liege=6674
de_jure_liege=6674
holder=558
name="Example Barony 3"
date=1232.2.8
heir={ 880 }
capital=6674
theocratic_lease=yes
coat_of_arms_id=2334
}
Thanks in advance. :)
The solution I eventually settled on, for discerning the overall code-blocks (e.g. all the data nested under 6674={ ... }) was basically:
Dim Code As String = File.ReadAllText("PATH/TO/CODE/FILE.txt")
Dim Output As List(Of String) = Code.Split(vbCrLf & "}" & vbCrLf).ToList
So in plain English, reading all the code into a single string, then splitting the string according to how the original code's language distinguished the initial nest of code (i.e. a carriage return followed by a curly bracket followed by another carriage return).
The list at the end would look something like this:
Output(0)
6673={" & vbCrLf & " key=""d_example_duchy_1""" & vbCrLf & " de_facto_liege=12" & vbCrLf & " variables={" & vbCrLf & " data={ {" & vbCrLf & " flag=""traditional_de_jure_kingdom""" & vbCrLf & " tick=0" & vbCrLf & " data={" & vbCrLf & " type=lt" & vbCrLf & " identity=6632" & vbCrLf & " }" & vbCrLf & " }" & vbCrLf & " }" & vbCrLf & " }" & vbCrLf & " de_jure_liege=6632" & vbCrLf & " de_jure_vassals={ 6674 6678 6682 6686 }" & vbCrLf & " holder=558" & vbCrLf & " name=""Example Duchy 1""" & vbCrLf & " date=1253.1.1" & vbCrLf & " heir={ 880 }" & vbCrLf & " history={ 1253.1.1=558 }" & vbCrLf & " capital=6674" & vbCrLf & " history_government=""tribal_government""" & vbCrLf & " coat_of_arms_id=2320
Output(1)
6674={" & vbCrLf & " key=""c_example_county_1""" & vbCrLf & " variables={" & vbCrLf & " data={ {" & vbCrLf & " flag=""influx_culture""" & vbCrLf & " tick=0" & vbCrLf & " data={" & vbCrLf & " type=culture" & vbCrLf & " identity=11" & vbCrLf & " }" & vbCrLf & " }" & vbCrLf & " {" & vbCrLf & " flag=""influx_faith""" & vbCrLf & " tick=0" & vbCrLf & " data={" & vbCrLf & " type=faith" & vbCrLf & " identity=57" & vbCrLf & " }" & vbCrLf & " }" & vbCrLf & " {" & vbCrLf & " flag=""fog_resistance""" & vbCrLf & " tick=0" & vbCrLf & " data={" & vbCrLf & " type=value" & vbCrLf & " }" & vbCrLf & " }" & vbCrLf & " }" & vbCrLf & " }" & vbCrLf & " de_jure_liege=6673" & vbCrLf & " de_jure_vassals={ 6675 6676 6677 }" & vbCrLf & " holder=558" & vbCrLf & " name=""Example County 1""" & vbCrLf & " date=1243.6.26" & vbCrLf & " heir={ 880 }" & vbCrLf & " capital=6674" & vbCrLf & " coat_of_arms_id=2323
And so on with the remaining three.

Deserialize non xml or json response from API

Been trying to figure out if there is a way to deserialize this object below. the problem is the api returns the data in this format. There seems to be an object here called Info that is listof()..
"found=23" & vbCrLf & "info[0].Channel=0" & vbCrLf & "info[0].EndTime=2020-05-11 00:59:59" & vbCrLf & "info[0].EnteredSubtotal=0" & vbCrLf & "info[0].ExitedSubtotal=0" & vbCrLf & "info[0].RuleName=NumberStat" & vbCrLf & "info[0].StartTime=2020-05-11 00:00:00" & vbCrLf & "info[1].Channel=0" & vbCrLf & "info[1].EndTime=2020-05-11 01:59:59" & vbCrLf & "info[1].EnteredSubtotal=0" & vbCrLf & "info[1].ExitedSubtotal=0" & vbCrLf & "info[1].RuleName=NumberStat" & vbCrLf & "info[1].StartTime=2020-05-11 01:00:00" & vbCrLf & "info[2].Channel=0" & vbCrLf & "info[2].EndTime=2020-05-11 02:59:59" & vbCrLf & "info[2].EnteredSubtotal=0" & vbCrLf & "info[2].ExitedSubtotal=0" & vbCrLf & "info[2].RuleName=NumberStat" & vbCrLf & "info[2].StartTime=2020-05-11 02:00:00" & vbCrLf & "info[3].Channel=0" & vbCrLf & "info[3].EndTime=2020-05-11 03:59:59" & vbCrLf & "info[3].EnteredSubtotal=0" & vbCrLf & "info[3].ExitedSubtotal=0" & vbCrLf & "info[3].RuleName=NumberStat" & vbCrLf & "info[3].StartTime=2020-05-11 03:00:00" & vbCrLf & "info
Thanks in advance for any ideas here.
Looks like it is VBscript.
vbCrLf means new line so:
"found=23"
"info[0].Channel=0"
"info[0].EndTime=2020-05-11 00:59:59"
"info[0].EnteredSubtotal=0"
"info[0].ExitedSubtotal=0"
"info[0].RuleName=NumberStat"
"info[0].StartTime=2020-05-11 00:00:00"
"info[1].Channel=0"
"info[1].EndTime=2020-05-11 01:59:59"
"info[1].EnteredSubtotal=0"
"info[1].ExitedSubtotal=0"
"info[1].RuleName=NumberStat"
"info[1].StartTime=2020-05-11 01:00:00"
"info[2].Channel=0"
"info[2].EndTime=2020-05-11 02:59:59"
"info[2].EnteredSubtotal=0"
"info[2].ExitedSubtotal=0"
"info[2].RuleName=NumberStat"
"info[2].StartTime=2020-05-11 02:00:00"
"info[3].Channel=0"
"info[3].EndTime=2020-05-11 03:59:59"
"info[3].EnteredSubtotal=0"
"info[3].ExitedSubtotal=0"
"info[3].RuleName=NumberStat"
"info[3].StartTime=2020-05-11 03:00:00"
I think this might be useful:
How to run VBScript in .net core or .net standard project?

Checking if destination exists when using CreateTextFile

I am making a form that the user fills out and when complete, they click a command button and the text they inputted is saved as a text file in a folder in the C: drive called Survey Results.
Currently, the user has to create the file "Survey Results" manually, and if it does not exist in the C: drive, there is an error in Word. I want some way to check if the destination exists before this error occurs and either prompt the user to create the folder or automatically create the folder.
What would I include in my while loop to check for this?
do while ()
messagebox1.open
loop
Private Sub CommandButton1_Click()
Dim FS As FileSystemObject
Set FS = New FileSystemObject
Dim MyFile As TextStream
Dim i As Integer
Dim FilePrefix As String, FileName As String, Extension As String
If CommandButton1.Enabled = True Then
FilePrefix = "C:\SurveyResults\"
Extension = ".txt"
i = 1
FileName = FilePrefix & comop & Trim(Str(i)) & Extension
Do While (FS.FileExists(FileName))
i = i + 1
FileName = FilePrefix & comop & Trim(Str(i)) & Extension
Loop
Set MyFile = FS.CreateTextFile(FileName)
MyFile.Write num1 & vbNewLine & num2 & vbNewLine & _
num3 & vbNewLine & num4 & vbNewLine & _
num5 & vbNewLine & num6 & vbNewLine & _
num7 & vbNewLine & num8 & vbNewLine & num9 & vbNewLine & num10 & vbNewLine & num11 _
& vbNewLine & num12 & vbNewLine & num13 & vbNewLine & num14 & vbNewLine _
& num15 & vbNewLine & num16 & vbNewLine & num17 & vbNewLine & num18 & vbNewLine & num19 & vbNewLine _
& num20 & vbNewLine & num21 & vbNewLine & num22 & vbNewLine & num23 & vbNewLine _
& num24 & vbNewLine & num25 & vbNewLine & num26 & vbNewLine & num27 & vbNewLine & num28 & vbNewLine _
& num29 & vbNewLine & num30 & vbNewLine & num31 & vbNewLine & num32 & vbNewLine & num33 & vbNewLine _
& com1a & vbNewLine & com1b & vbNewLine & com1c & vbNewLine & com1d & vbNewLine & com1e & vbNewLine _
& com1f & vbNewLine & com1g & vbNewLine & com1i & vbNewLine & com1j & vbNewLine & com1k & vbNewLine _
& com2a & vbNewLine & com2b & vbNewLine & com2c & vbNewLine & com2d & vbNewLine & com2e & vbNewLine _
& com2f & vbNewLine & com2g & vbNewLine _
& com3a & vbNewLine & com3b & vbNewLine & com3c & vbNewLine & com3d & vbNewLine & com3e & vbNewLine _
& com3f & vbNewLine _
& com4a & vbNewLine & com4b & vbNewLine & com4c & vbNewLine & com4d & vbNewLine & com4e & vbNewLine _
& com4f & vbNewLine & com4g & vbNewLine & com4h & vbNewLine & com4i & vbNewLine & com4j & vbNewLine & com4k & vbNewLine & com4l & vbNewLine _
& com5a & vbNewLine & com5b & vbNewLine & com5c & vbNewLine & com5d & vbNewLine & com5e & vbNewLine _
& com5f & vbNewLine & com5g & vbNewLine & com5h & vbNewLine & com5i & vbNewLine & com5j & vbNewLine _
& com6a & vbNewLine & com6b & vbNewLine & com6c & vbNewLine & com6d & vbNewLine _
& com1hb & vbNewLine & com1hd & vbNewLine _
& com1hf & vbNewLine & com1hh & vbNewLine & com1hj & vbNewLine & comop
End If
End Sub
Do something like the below snippet:
Dim FilePrefix$, fs As New Scripting.FileSystemObject
FilePrefix = "C:\SurveyResults\"
If Dir(FilePrefix, vbDirectory) <> "" Then
'directory exists
Else
'directory does not exist
fs.CreateFolder FilePrefix ' create the dir
End If

Format Exception Error when writing text to a file in VB

When I try to write text to a file, I get an error saying "FormatException was unhandled"
Here's the code:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Dim ChampPath As String = FolderBrowserDialog1.SelectedPath & "\League of Legends\Config\Champions"
Dim NamePath As String = ChampPath & "\" & SelectChampion.Text
Dim FilePath As String = NamePath & "\" & SelectChampion.Text & ".json"
Dim Map As String
Dim Mode As String
System.IO.Directory.CreateDirectory(NamePath)
System.IO.File.Create(FilePath).Dispose()
If (SelectMap.Text = "Any") Then
Map = "any"
ElseIf (SelectMap.Text = "Summoners Rift") Then
Map = "1"
ElseIf (SelectMap.Text = "Twisted Treeline") Then
Map = "10"
ElseIf (SelectMap.Text = "Crystal Scar") Then
Map = "8"
ElseIf (SelectMap.Text = "Proving Grounds") Then
Map = "3"
End If
If (SelectMode.Text = "Any") Then
Mode = "any"
ElseIf (SelectMode.Text = "Classic") Then
Mode = "CLASSIC"
ElseIf (SelectMode.Text = "Dominon") Then
Mode = "ODIN"
ElseIf (SelectMode.Text = "Proving Grounds") Then
Mode = "ARAM"
End If
If (System.IO.File.Exists(FilePath)) Then
Using Writer As StreamWriter = New StreamWriter(FilePath)
Writer.Write("{" & vbNewLine &
" ""champion"":""" & SelectChampion.Text & """," & vbNewLine &
" ""title"":""" & TitleBox.Text & "", " " & vbNewLine &
" ""type"":""" & TypeBox.Text & "", " " & vbNewLine &
" ""map"":""" & Map & "", " " & vbNewLine &
" ""mode"":""" & Mode & "", " " & vbNewLine &
" ""priority""" & SelectPriority.Text & "", " " & vbNewLine &
" ""blocks"":[ " & vbNewLine &
"{" & vbNewLine &
" ""type"":""starting"", " & vbNewLine &
" ""items"":[ " & vbNewLine &
"{" & vbNewLine &
" ""id"":""1001"", " & vbNewLine &
" ""count"":1 " & vbNewLine &
"}," & vbNewLine &
"{" & vbNewLine &
" ""id"":""3010"", " & vbNewLine &
" ""count"":3 " & vbNewLine &
"}" & vbNewLine &
"]" & vbNewLine &
"}," & vbNewLine &
"{" & vbNewLine &
" ""type"":""essential"", " & vbNewLine &
" ""items"":[ " & vbNewLine &
"{" & vbNewLine &
" ""id"":""3001"", " & vbNewLine &
" ""count"":1 " & vbNewLine &
"}," & vbNewLine &
"{" & vbNewLine &
" ""id"":""3089"", " & vbNewLine &
" ""count"":1 " & vbNewLine &
"}" & vbNewLine &
"]" & vbNewLine &
"}," & vbNewLine &
"{" & vbNewLine &
" ""type"":""offensive"", " & vbNewLine &
" ""items"":[ " & vbNewLine &
"{" & vbNewLine &
" ""id"":""3100"", " & vbNewLine &
" ""count"":1 " & vbNewLine &
"}," & vbNewLine &
"{" & vbNewLine &
" ""id"":""3128"", " & vbNewLine &
" ""count"":1 " & vbNewLine &
"}," & vbNewLine &
"{" & vbNewLine &
" ""id"":""3135"", " & vbNewLine &
" ""count"":1 " & vbNewLine &
"}" & vbNewLine &
"]" & vbNewLine &
"}," & vbNewLine &
"{" & vbNewLine &
" ""type"":""defensive"", " & vbNewLine &
" ""items"":[ " & vbNewLine &
"{" & vbNewLine &
" ""id"":""3140"", " & vbNewLine &
" ""count"":1 " & vbNewLine &
"}," & vbNewLine &
"{" & vbNewLine &
" ""id"":""3157"", " & vbNewLine &
" ""count"":1 " & vbNewLine &
"}" & vbNewLine &
"]" & vbNewLine &
"}" & vbNewLine &
"]" & vbNewLine &
"}")
End Using
End If
End Sub
I can't find where the error is actually coming from...
The text also needs to be formatted like it is, with the quotes and what not. Thanks for any help.
Assumed VB Net .. Better you change like this
Writer.Write("{" & vbNewLine & _
" champion : " & SelectChampion.Text & "," & vbNewLine & _
" title : " & TitleBox.Text & "," & vbNewLine & _
" type : " ........
...... etc