VS 2010 Reading Chars From A String?
Nov 11, 2011
still pretty new to programming in general, but I have most of the basics figured out.I stumbled across this problem today, though. I wanted to try making a simple encoder/decoder. However, I am having trouble getting characters from a string.
I have a list(of char) to separate the individual letters in the message (letterList), and textToConvert is the text that the user types in to be encoded. Here's the section of code my problem exists in:
For i = 0 To textToConvert.Length - 1
letterList(i) = textToConvert.Chars(i)
Next i
Upon running my program, I get an out of range exception for the middle line above. Am I doing something wrong?
View 3 Replies
ADVERTISEMENT
Dec 6, 2009
Im trying to read encrypted text from a text file but when i try to read it i would get boxes in stead of the encrypted text.
View 1 Replies
Oct 8, 2011
In VB.net I've got the following line that removes all non-alphanumeric chars from a string:
return Regex.Replace(build, "[W]", "")
I now need to extend this to remove non-alphanumeric chars that aren't [] or _. I've changed the line to:
return Regex.Replace(build, "[W[]_]", "")
However I'm pretty sure that this says
replace non-word or [ or ] or _
how do I negate the tests for the [] and _ chars so that it says
replace non-word and not [ and not ] and not _
Some examples:
"[Foo Bar_123456]" => "[FooBar_123456]"
"[Foo Bar_123-456*]" => "[FooBar_123456]"
View 2 Replies
Nov 20, 2010
How to convert or make a cast of a List object typized as a container of chars like
Dim mylist As List(Of Char) = New List(Of Char)(New Char() {"1"c, "2"c})
in a simple array of chars as
Dim mychars() As Char
without make a loop for...
View 1 Replies
Apr 4, 2011
I am making an antivirus program and i am having a problem with my database. how can i only get the hash in this string:
693248:ff807bd383d377f7f8f91ed4aa7677ae:Trojan.Agent-178374
i only want between the two ":"s in this string. how is this possible? and also how do i get the last part on the right of the last ":"?
View 3 Replies
Oct 29, 2009
I'm data binding to a label in a grid and need to knock off the last two chars, not so easy as I thought.I know this is wrong it just shows how I'm coding:
Code:Private Sub TemplateControl_DataBinding_Label(ByVal sender As Object, ByVal e As System.EventArgs)
[code].....
View 4 Replies
Mar 25, 2010
if the last 4 chars in my string(result) are " AND" or the last three chars are " OR" I would like to remove these from the string. So far I have am trying result.trimend and a few other methods but am unsure how to get it working.
View 3 Replies
Apr 14, 2010
this is driving me crazy , I have a string like this dim s as string = "<a href="url.aspx? target=_BLANK>mik, H</a>" I want to remove "mik, h" from the string, how can i do that?
View 4 Replies
Apr 18, 2011
I am using TrimEnd to remove certain chars from the end of a string. Initially I thought this would work:
[Code]...
View 2 Replies
Feb 23, 2012
I'm trying to read a file with my following sub:
Public Declare Function GetPrivateProfileString& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnedString$, ByVal RSSize&, ByVal FileName$)
[Code].....
View 13 Replies
Dec 21, 2010
i have a VB.NET program that handles the content of documents. The programm handles high volumes of documents as "batch"(>2Million documents;total 1TB volume) Some of this documents may contain control chars or chars like f0e8 [URL]). Is there a easy and especially fast way to remove that chars?(except space,newline,tab,...) If the answer is regex: Has anyone a complete regex for me?
View 2 Replies
Nov 11, 2009
tell me how to Count Special Characters from input STRING.
View 2 Replies
Oct 29, 2009
Using VB.NET 2003 Asp.Net 1.1. I'm data binding to a label in a grid and need to knock off the last two chars, not so easy as I thought.
I know this is wrong it just shows how I'm coding:
Code:
<div id=CODE>Private Sub TemplateControl_DataBinding_Label(ByVal sender
As Object, ByVal e
As System.EventArgs)
Dim lc As Label
Dim sColumnName As
String = ""
[Code] .....
One problem is what I want to achieve:
I want to have:
$123.00
$15.00
$1,000.00
$123.50
$45.78
My data comes back with 4 places on the end
123.0000
15.0000
45.7800
35.9000
The $ sign I have in my code does work
so I have"
$123.0000
$15.5000
and so on.
I don't believe there will ever be a point where the last two are anything other than zeros.
View 3 Replies
Feb 29, 2012
I am not sure if this makes sense or not,but I need to process raw text(without any encoding?) that I retrieved from a file recovery application "PhotoRec"
With an application like Notepad++ I can see all of the text I need to manipulate but with VB I seem to only get some of the text with other stuff stripped out.Here is what I am using to process the file:
[code]...
I essentially add each line of text to the collection so I can read each line at a time (other processing, etc.)So, as mentioned, with the above code I get text but not all of it. With different encodings I get different versions of the text represented in "currentbyte".So, how can my .NET application read text like Notepad++ or a similar "raw" text reader app?
View 3 Replies
Mar 3, 2011
I'm trying to make a hash calculator (For testing now)
I know that MD5 is a 1 way(Meaning that there is no decryption for it, yet)
now I was wondering if SHA-1 is a two way. Also, is there any other hashing method that are 2way?
reason is that I want to convert a long string (Lets say 550 chars) into something lower (From 550chars to something lower then 550chars)
I can use a Key, but every possibility will give me bigger length then the actual string.
View 6 Replies
Sep 7, 2011
I can write a 1-d string array to file with:
Dim test() As String = {1, 2, 3, 4, 5}
File.WriteAllLines("C:MyFile.txt", test)
but can't see how to write a 2-d array to file.
I've tried this:
Dim test(,) As String = {{1, 2, 3, 4, 5}, {34, 22, 12, 33, 55}}
Dim myfile = File.CreateText("C:MyFile.txt")
Dim row, col As Integer
[Code].....
View 4 Replies
Dec 16, 2009
I am testing for a string if it contains at least n chars in consecutive order: I have this regex but it doesn't seems to work (w1){3,}
View 2 Replies
Jun 30, 2010
I'm using the following to strip special characters out of a URL:
Dim urlReg As New Regex("[^dw ]")
inurl = urlReg.Replace(inurl, "")
[code]......
View 2 Replies
May 5, 2009
I have text file with a row like this:
[Code]...
View 2 Replies
Nov 10, 2011
I'll explain the scenario. I have a list containing character list and it's corresponding unicode characters(copied from CharMap and pasted in VB editor).
For example:
Text = Unicode --> Unicode character
---------------------------------------
K = U+004A --> J
[code].....
View 2 Replies
Apr 15, 2010
I'm creating a radio streaming application, which plays a live stream from various radio stations in a small 'gadget' like application.
The user can add his own custom radio stations, by supplying a Name, a StreamUrl and, optionally, an Image that represents a logo or something of that radio station.The logo will be drawn on the main form when that station is selected.
I need to be able to save these custom stations, and I think it makes sense to use an XML file, which could then look something like this
<CustomStations>
<Station>
<Name>Radio 1</Name>
[code]....
Before I added the support for images, this worked fine, how to store the images. I want the user to be able to select any image from his harddrive, but I don't want to force him to keep that image in the same location afterwards. So I can't rely on the path that he selected. Instead, I want to simply load the image from the path he selected, and then save it somewhere else.
I am storing the XML file in the common application data path which I think is a good place for the images too.The problem is, how to determine a name for the images? I will always have just one image per custom radio station, so it makes sense to me to simply have one Images folder that holds all images, with a unique name.I can see two solutions:
1. Generate a random filename for every image
2. Use the Name of the radio station as the image name
For option 1, I suppose I could just create a string of 16 random characters and call that the filename. The problem of course is that there is no guarantee that I will get a unique filename. Yes, the chances of generating the same name twice randomly are very tiny, but it's still possible, and I just don't like that. How can I ensure that my random filename is unique? I suppose I could always drop the whole thing in a While loop that continues when the new filename already exists, but there must be a better way... Is there nothing in the framework that allows me to generate a unique random filename, in a directory of my choice (so not in the Temp directory...)
I like option 2 much better. The Name of a radio station is unique (there can't be two stations with the same name), so I don't have to worry about filenames conflicting. The problem with this approach is that there are no restrictions on the name. There's nothing stopping the user from naming their custom station "Radio~/aij!""_.fe" or something like that, which is obviously not a valid filename... So, I will have to do 'something' to generate a valid filename from the station name. I could simply remove all non-valid path characters from the name, but then I am no longer guaranteed a unique filename... Suppose there's two stations, one called "Radio/1" and one "Radio1", then after removing the invalid "/" character, the names will be the same and so I will generate the same image path for both....
View 8 Replies
Mar 26, 2011
I've always been slightly stumped as to why the following happens if I write[code]...
View 4 Replies
Mar 18, 2012
I'm having a little trouble trying to read a word document in vb. how to get the text out of the word document would be great.
View 4 Replies
Mar 30, 2012
I'm making a program that can read a game music file and able to add some texts after it.So far, this is my code:
For Each foundFile As String In My.Computer.FileSystem.GetFiles("E:O2ChinaMusic", _
FileIO.SearchOption.SearchTopLevelOnly, "*.ojn")
Dim fileName As String = IO.Path.GetFileNameWithoutExtension(foundFile) 'Filename[code]....
My problem is for example, the game music file's title is "Puberty", as you can see, my code is:
StrItm(1) = title & " INPUT TEXT HERE"
but the only one that appear is the word "Puberty" AND NOT "Puberty INPUT TEXT HERE".
View 8 Replies
Dec 12, 2011
I done this:
sTxt = File.ReadAllText("C:someWebPage.html")
View 7 Replies
Nov 12, 2011
I'm making a calculator that would read a "string" from a textbox and parse it and follow Order-of-Operations/PEMDAS on the string. I have a couple of questions:
1) What would be the best way to parse the code so that it won't just take a "left expression" and "expression" and perform the operation on those 2.
2)How would I be able to make is so that 0 is considered valid, but prevent a 00 or 020 or 002 to be inputed.
View 3 Replies
Sep 28, 2011
I'm in the process of creating a tile based game. This game requires a method to load a text file and write the numbers between the delimiter "-", to a multidimensional array. However, an error message "object not set to an instance occurs. [code]...
View 4 Replies
Oct 22, 2009
For starters I'm using VB 2008 express edition.I have code that writes a string out of a serial port.My issue is that the machine sends data back and I don't know how to catch it.This is my latest attempt at creating an array of characters to create a string later but doesn't work.[code]
View 2 Replies
May 1, 2012
i have a number in this format: 123 and I want a select statement such as below for comparsion so i dont have as many if statements:
Select case numbers(i)
case is = "123"
case is = "234"
example but in real scenario numbers are random.
Heres my code in which all select cases dont get fired:
Public Function UserAdd() As String
On Error GoTo Errorhandler
Dim personcount As Integer
[Code]....
But the case is statements above dont fire when I know that number is correct above
View 9 Replies
Aug 20, 2010
This code should read the string "34,56,23,74,69" from a process's memory addresses (in this case notepad), right now it works but very slow and I think it even breaks somewhere. My problem is with the ReadProcessMemory function. I can't make it read an entire mbi.RegionSize into the buffer. I tried everything and now, it only reads 1 byte at a time until the mbi.RegionSize is finished then it checks if the text that was read contains the text I need to be found, then it goes to the next mbi.RegionSize. Now, even with notepad which is very small it still takes 10 seconds to find something and I intend to use it with a much bigger program, so it will take like forever. Another problem is that it only finds the string "34". If I put "34,5" it won't work.
Imports VB = Microsoft.VisualBasic
Imports System.Runtime.InteropServices
Imports System.Security.Permissions
Public Class Form1
Inherits System.Windows.Forms.Form
[Code] .....
View 3 Replies