How to store specific part of youtube URL - VB [closed] - vb.net

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I have a form with a textbox. In the textbox the user will insert a youtube link such as: 'https://www.youtube.com/watch?v=IJNR2EpS0jw' . However I only need this part of the URL 'youtube.com/watch?v=IJNR2EpS0jw' . So my question is how can I write a code to store the selected part of the URL I need. I think it needs to start of like this:
Dim specificurl As String
specificurl = TextBox1.Text.StartsWith("youtube.com")
Regards

You can use the String.Replace method to strip the https://www. out of the string.
Dim URLString As String = "http://www.youtube.com/watch?v=..."
URLString = URLString.Replace("https://www.", "")
URLString = URLString.Replace("http://www.", "")
This will get you the value you're looking for.

If there's any chance your input may have capital letters (unlikely since this is a URL), you'd need to use Regex to do the replacement (this would also let you do both HTTP and HTTPS in one line):
Dim newValue As String = Regex.Replace(input, "^https*://", String.Empty,
RegexOptions.IgnoreCase)

Related

How to name boolean variable that indicates whether to do something? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
As far I as my experience tells me, boolean variables usually named in format - is/has+noun/adj/verb, e.g isValid, isButton, hasClickedLink
But say there is the case where we have some flag which straightly tells whether to do something, like for example, clean to indicate that cleanup function should be automatically called in the end.
How to name such a booleans? Same clean - is ambiguous, looks like a method name more, but naming it toClean is, I don't know, too weird. Or should I name it like callCleanup?
Thanks in advance!
In this case i usually append the word wanted, which makes cleanWanted. In general, for boolean variables I also prefer to always let the last word be an adjective. This makes it very clear that it represents a truth value. The is/has prefix is often superfluous, as in hasClickedLink which is more concisely communicated with linkClicked.
methods are usually one word adjectives with a capitol at the start
maybe create a method that sets the flag
for example
void Clean(){
clean = True;
}

Parsing JSON string with Chinese character [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
The are various question similar to my problem I have found on SO but none of them are able to solve the issue I am having. I have been provided a text file which contains the following string,
callback12({
"searchResult":{
"data":[
{
"CURRENCY":"人民币",
"DATE":"2016-03-25",
"NAME":"仲尧文"
},
{
"CURRENCY_TYPE":"人民币",
"DATE":"2016-03-24",
"NAME":"王新华"
}]
}
})
I am using following line of code to parse the JSON string,
Dim objTempResults As JObject = JObject.Parse(strSource)
Dim objResults = objTempResults("callback12")("searchResult")("data").Children()
But it is giving me the exception on JObject.Parse that,
Unexpected character encountered while parsing value: \. Path '', line 0, position 0.
The other questions that I have found have answers to encode and decode the string but I cannot encode or decode the whole string as there are only two fields which needs to be encoded. How can I solve this exception?
The Chinese characters in the JSON are not the problem here. You are getting a parse error because your JSON is wrapped inside a javascript function call, which makes it invalid JSON. (See JSON.org for details on what is considered valid JSON syntax.) If you remove the callback12() surrounding the JSON, it will parse correctly with Json.Net.
Fiddle: https://dotnetfiddle.net/xN5JJi

Convert UID null-termintated string binary to hex [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Here is the question which is Re Phrased.
Here is the raw binary data, hex encoded, which i need as a output:
040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000310000007643616C2D5569640100000033353335324538372D343338462D343444362D413432462D37393942423334313033333800
I can extract some part of the raw data i.e.(040000008200E00074C5B7101A82E0080000000000000000000000000000000000000000310000007643616C2D55696401000000) from the object which i am getting from the micro soft outlook.
The Rest of the part that is
33353335324538372D343338462D343444362D413432462D373939424233343130333338 is the conversion of the UID : 373D06E9-587E-4930-B846-12500FF1AC2F.
So My question here is how to convert the above UID i.e 373D06E9-587E-4930-B846-12500FF1AC2F to this format 33353335324538372D343338462D343444362D413432462D373939424233343130333338 using objective C or cocoa.
Thanks in Advance.
You should look here:
https://developer.apple.com/library/mac/documentation/corefoundation/Reference/CFUUIDRef/Reference/reference.html#//apple_ref/c/func/CFUUIDCreateFromString
CFUUIDCreateFromString() appears to be the API you are looking for. Assuming that CFUUID is the "binary format" you are searching for.
If you then want "raw bytes", look at CFUUIDGetUUIDBytes()

String.Format For SQL Connection String [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I need to convert a SQL connection string into a String.Format line
The line that I need to convert is this:
WHERE full_name = #FullGraveNumber AND cemetery_id = #CemeteryID
Both thefull_name and cemetery_id are variables, but I have not idea how to construct the
String.Format line.
Seems you are looking for
Dim selectCommand = "SELECT * FROM mytable WHERE full_name = #FullGraveNumber AND cemetery_id = #CemeteryID"
Dim cmd = New SqlCommand(selectCommand, yourconnetion)
cmd.Parameters("#FullGraveNumber").Value = value1
cmd.Parameters("#CemeteryID").Value = value2
or
cmd.Parameters.AddWithValue("#FullGraveNumber", value)
First of all, ConnectionString is already a String with no parameters, it does not need to converted using String.Format. Usually stored in app.config, you feed it directly into SqlConnection object upon creation.
Part of the query that you have is also a String, but this time it may be substituted with parameters. However, please don't do so and use SQL parameters instead (see #huMpty's answer).
full_name and cemetery_id are SQL parameters, variables is something else.
My suggestion it to learn the terminology first, before you do any coding. No offense, it would benefit you a lot, because you would be able to ask a proper question. Proper question means a fast and qualified answer. Improper questions are usually closed. These are the rules of StackOverflow.

How to pluralize a function's name in technical writing? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
How to pluralize a function's name such as foobar in technical writing?
By technical writing i mean, for example, comment text in source code, documentation of a software or programming element that might be in different place from the corresponding source code.
Should i use
foobars
foobar`s
foobar's
foobar
?
I'd suggest not changing the function/method name in any way as that would invite confusion, but refer to it like:
Use the fooBar functions to blah, blah, blah...
or
Use the fooBar methods to blah, blah, blah...
Add the "s" at the end like any other plural, but distinguish via formatting.
Write something like "All of the substrs are...". I also will distinguish a function name as a function name by using parentheses, as in "All of the substr()s are ...".