vb.net reading text between custom tags in text file - vb.net

I am looking to put settings data values like user/password in one file. I seen it before. I need some assistant to do it in VB.NET
Text file would be formatted like bellow:
[TAG]
[USERS]
JOHN DOE,1234,1
JANE DOE,4321,2
[COLOR]
RED,1
WHITE,2
BLUE,3
[/TAG]
How could I read in between these tags in a text file?

My Favorite, aside from writing a custom parser for very easy files, would be to use the Nini library.
In particular, look at this page that shows your exact file type.
Hope that helps!

Related

JDownloader2: Formatting links for Linkgrabber

Is there any way of formatting a list of links in a text file, so JDownloader's Linkgrabber knows the package name I want?
For example:
{{packagename1}}http://link-a
{{packagename1}}http://link-b
{{packagename2}}http://link-c
{{packagename3}}http://link-d
{{packagename4}}http://link-e
{{packagename4}}http://link-f
Will put link-a and link-b in "packagename1", link-c in "packagename2", link-d in "packagename3", and link-e and link-f in "packagename4".
Someone in Reddit pointed me to the solution.
If we look in Settings / Packagizer, there's a rule editor.
A custom rule can be made that takes links in the format:
http://link-a#packagename=packagename1
Which puts the downloads found in the link in a package named "packagename1".
(Original image by the user that provided the answer, grooters)

Asp.NET database multi-lang design [Include HTML]

,
I read lots of answer here and learn something about this topic but I need more help.Some pages in my project are getting the html(page body) from database.For my controls I use resx files and it works great, but now I need save the html values with multi-lang in my database.
I have a admin panel for my project and I edit sometimes the html or text or pictures in my editor and save it back to DB.I cache the html values in my website and get better performance for my project.But the html text parts is yet in my default lang I will create multi-lang.
I thought of a few possible solutions,
First solution was copying all of the same HTML data and create for all lang one by one
First solution problem : But later this doesnt make sense If I copy the values and create for other lang, then I had be repeating unnecessarily in my database the html values.
My second solution was like this :
this I hid it in the normal way in my DB (only a part of html in one column)
<li>Hello World</li>
<li>Hello Me</li>
Solution :
<li>[HelloWorld]</li>
<li>[HelloMe]</li>
string newHtmlValue = oldValue.ReplaceByLang("[HelloWorld]", GetCulture();,"Hallo Welt");
***// GetCulture(); return for this example german !
I create a new table for the replace text like the key is [HelloWorld]
1(ROW)- [HelloWorld] eng Hello World
2(ROW)- [HelloWorld] german Hallo Welt
3(ROW)- [HelloWorld] fr bonjour tout le monde
and in my project I select the right html value by culture lang.
Now my question is have you any better idea ?
I hope I've been clear and not messy, but if you need more informations I'll be glad to tell you more.Sorry for english.
I would prefer to store all your localized string in single repository like - DB or Satellite assembly.
For Example if you choose DB as repository - Define 3 tables (minimal structure)
1.Locale - Define your locale
2.Resourcemaster - Define your source string and reference Key and this key should be unique in you application and define a standard format like Module_Control_Section ..
3.LocalizedResource - Define your localized sting of Resourcemaster with Locale Key. Foreign key with ResourceMaster and Locale
In front End you can resole any string like control , Html string with localized string and Unique reference key.
Also Implement UI Caching / API caching for better performance.
Regards
Abdul

how can i export DataGridView with ARABIC data from Visual Basic to PDF by using iTextSharp [duplicate]

I have a problem with inserting UNICODE characters in a PDF file in eclipse.
There is some solution for this that it is not very efficient for me.
The solution is like this.
document.add(new Paragraph("Unicode: \u0418", new Font(bfComic, 12)));
I want to retrieve data from a database and show them to the user and my characters are in Arabic script and sometimes in Farsi script.
What solution do you suggest?
thanks
You are experiencing different problems:
Encoding of the data:
Please download chapter 2 of my book and go to section 2.2.2 entitled "The Phrase object: a List of Chunks with leading". In this section, look for the title "Database encoding versus the default CharSet used by the JVM".
You will see that database values are retrieved like this:
String name1 = new String(rs.getBytes("given_name"), "UTF-8");
That’s because the database contains different names with special characters. You risk that these special characters are displayed as gibberish if you would retrieve the field like this:
String name2 = rs.getString("given_name")
Encoding of the font:
You create your font like this:
Font font = new Font(bfComic, 12);
You don't show how you create bfComic, but I assume that this object is a BaseFont object using IDENTITY_H as encoding.
Writing from right to left / making ligatures
Although your code will work to show a single character, it won't work to show a sentence correctly.
Suppose that name1 is the Arabic version of the name "Lawrence of Arabia" and that we want to write this name to a PDF. This is done three times in the following screen shot:
The first line is wrong, because the characters are in the wrong order. They are written from left to right whereas they should be written from right to left. This is what will happen when you do:
document.add(name1);
Even if the encoding is correct, you're rendering the text incorrectly.
The second line is also wrong. The characters are now in the correct order, but no ligatures are made: ل followed by و should be combined into a single glyph: لو
You can only achieve this by adding the content to a ColumnText or PdfPCell object, and by setting the run direction to PdfWriter.RUN_DIRECTION_RTL. For instance:
pdfCell.setRunDirection(PdfWriter.RUN_DIRECTION_RTL);
Now the text will be rendered correctly.
This is explained in chapter 11 of my book. You can find a full example here: Ligatures2

PHPExcel write html file into existing xlsx file

I have a template file that I fill using PHPExcel. But I have terms and conditions that are saved in database with html tags and inline css. Now these terms and conditions are subject to change so I cant put it into template. So only solution is t take it from database and put it inside created template but I have no clue how to open xlsx file and insert .html file inside it perhaps as second sheet.
This is my current code:
$objPHPExcel = new PHPExcel();
$objPHPExcel = PHPExcel_IOFactory::load($inputFileName);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');
$objWriter->save($outputFileName);
And of course there is lot of code that specifically deal with writing data to excel file but that is working perfectly.
Could someone please explain how could I go about doing it.
Thanks
You can't simply insert an HTML file inside an xlsx file
The latest develop branch of PHPExcel does include an HTML to Rich Text wizard that will take a block of HTML markup and convert it to a Rich Text object that can then be stored in a cell, and /Examples/42richText.php demonstrates how it can be used. At present, this only covers basic markup tags (<br />, <font>, <b>, <i>, <em>, <strong>, <sub>, <sup>, <ins>, <del>, etc) and doesn't handle inline style in any way. However, it might provide the basis for what you want with some additional work.

How to find some text on webpage and show it in textbox (or just write it out) using Visual Basic?

Let's say I have a www.exmple.com website, with some text on it;
Example 1
Example 5713
Example 151
Example ...
and so on...
I would like to create a program where the user could input what is he looking for ON www.example.com... Like he is type "Example 151", it will show in a new textbox or something that can actually store text.
Is this possible?
I hope someone can help,
Thank you!
Is this possible?
Yes, certainly. You need to use an HTML parser - a library that can read the HTML and that you can then query it for.
Two popular options are the HTML Agilty Pack (uses XPath for querying) and CsQuery (uses jQuery like query syntax).