Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Binary String Manipulation


Im curious if this is even possible in visual basic.

You know how you can open a file for binary??

Then you can step through it and get Bytes, and Integers like this...

Open sFile for binary as #1
Get #1, , bTemp
Get #1, , iTemp
Get #1, , iTemp
close #1

I want to put variables into a string, in a binary form.
Now I want to step through a string, and grab the variables in the same way.

The only way I know how is my character, but I want it per byte.
I dont know how to make a string into bytes either.

can anyone help me?>




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
.file To Binary>manipulation
hey dudes
i was thinking of doing this just to see if it can be done.
basically it to "encrypt" files,
what i was thinking is
to read a file, eg .txt, .doc, .xls, etc etc etc with vb as its binary digits.
then go through all of the digits and change all 1's to 0's and all 0's to 1's, then save the file.
obviously this will garble the file.
then to ungable just do the exact same process.

is this possible?
i dont know much of vb, so any info [no matter how basic] is appreciated.

Binary Level File Manipulation Help
I need help inserting or editing files at binary level.
For instance, How does someone insert data right after
the 52nd byte or any user definable byte of a file?
The data being inserted is most probably raw data from another file
I really need help because i'm really new to VB. Thanks a lot.

String Manipulation (Extracting Alphanumeric Characters From A Mixed String)
If the value of something always contains both letters and numbers, how can I extract just the letters from the String?

String Manipulation:Remove Html Tag In A String
i have a simple function as below:


PHP Code:





Public Function FormatData(InpData as String) as String
Dim s,c As String
Dim a,b As Integer
s = InpData
a=InStr(s, ">")
If a=0 Then
Return s
Else
b=Instr(a,s, "<")
c=Mid(s,a+1,b-a-1)
Return c
End If
End Function 







This function is to remove the html tag of the input data.
For example <Strong>Approved</strong> will become Approved.

The function above is able to remove a single tag but not able to removed multi tag like <Strong><u>Approved</u></Strong>

Any idea? Thanks.

String Manipulation Help. String To Date?
How would I convert the following strings:

1. "3162007" into 03/16/2007
2. "10252007" into 10/16/2007

Any suggestions would be appreciated. Thanks

Vba String Manipulation
I have a string declared as

Dim MyString As String

My question is: How do I make this string "Bold"?

Is there a VBA utility to do this?

Thanks in advance

String Manipulation
Hi, I have a series of strings which always contain 12 digits, i.e, 853408410000

What I would like to do is take away the first 2 digits and the last 4 digits to leave me with:

340841

I have looked at the othher string manipulation thread, but it invloved spaces, so I don't really know where to start. Any help would be appreciated thanks.

String Manipulation
I have a string, in a string, that I am trying to extract

I am using the Split & Ubound function for the left side of the string:

sometexthere whatineed sometexthere

which will result in:

whatineed sometexthere


My question is, what function should I use to split the right side? I was looking into various things like InStrRev, Mid, etc. but I'd like some more info. on what function I should be using. The string is not always the same length either, which was why I'm skeptical of using Mid, maybe it's possible though

String Manipulation
hi all, i was wondering, how do i get a caption to display some sort of chariceter repeated, depending on another number? such as i have a string and i get the number of that string and i want to display a charicter that many number of times in one label.
this is what i thought it would be:

lblOutput.caption = "@" * len(strWord)

i keep getting type mismach errors>

any suggestions?

String Manipulation
HI, I working in this solution, that create an user account .
-the username is the first letter of the firstname and the lastname combined
for example: John Smith = JSmith
-the Password is the username with random nummber inserted.to display the password i need to make a loop , that loop 3 times,within the loop creade a random number, insert the random number at the location in the string equal to the random number minus 1.
for example: J258Smith
my Problem is that i dont know how to code, the usernameand password,
here is muy code
CODE

Private Sub BtnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnExit.Click
Me.Close()
End Sub
Private Sub clearform()
Me.TxtFirstName.Text = ""
Me.TxtLastName.Text = ""
Me.TxtLength.Text = ""
Me.TxtState.Text = ""
End Sub
Private Sub BtnClear_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnClear.Click
'Clear Textboxes
Call clearform()
Me.LblBasePrice.Text = ""
Me.LblDiscountPrice.Text = ""
Me.LblPassword.Text = ""
Me.LblUserName.Text = ""
End Sub
Private Function Getprice(ByVal strState As String) As Decimal
Dim decBasePrice As Decimal
Select Case strState
Case "NH"
decBasePrice = 20
Case "MA", "ME", "VT"
decBasePrice = 30
Case Else
decBasePrice = 40
End Select

Return decBasePrice

End Function


Private Sub BtnCalc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnCalc.Click
Dim strFirstName, strlastName, strState, strUsername As String
Dim decBaseprice As Decimal
Dim strpassword As String
Dim intnum1 As Integer
Dim intcount As Integer
Dim rnd As New Random
Dim intrandom As Integer


If Me.TxtFirstName.Text <> "" And Me.TxtLastName.Text <> "" And Me.TxtState.Text <> "" Then
strFirstName = Me.TxtFirstName.Text
strlastName = Me.TxtLastName.Text
strState = Me.TxtState.Text
strpassword = Me.LblPassword.Text
strUsername = Me.LblUserName.Text
'set price
decBaseprice = Getprice(strState)
'change new name and password
strUsername = strlastName.Insert(1, strFirstName)



Do While intcount < 3
intnum1 = rnd.Next(0, 7)
Me.LblUserName.Text = intnum1.ToString()
intcount = intcount + 1
Loop

If Me.TxtLength.Text < 5 Then
Me.LblDiscountPrice.Text = decBaseprice - 0.5
Else
Me.LblDiscountPrice.Text = decBaseprice - 0.1

End If
'set labels
Me.LblPassword.Text = Me.LblUserName.Text & strUsername
Me.LblBasePrice.Text = decBaseprice.ToString("c2")
Me.LblUserName.Text = strUsername

End If

thanks in advance...



Full Edit
Quick Edit

String Manipulation Help
I'm trying to extract the number that come after "user=" and place it in a listbox. The code I have places two of the same numbers. How do I get the program to first look at the "<td class="pic">" and then manipulate the HTML that comes after it? I tried o.className="pic", but that didn't work.

Here's the HTML code:

HTML Code:
<tr>
<td class="pic"><a href="http://www.domain.com/index.cfm?user=120747809">
<img src="http://www.domain.com/images/1478100240_s.jpg" /></a></td>
<td><a href="www.domain.com/index.cfm?user=120747809"></a><font></font>
<b></b></td>
</tr>
Here's my code:




Code:
Dim o As Object
For Each o In wb.Document.links
If wb.LocationURL Like "*domain.com/music*" Then
If o.href Like "*domain.com/index.cfm?user=*" Then
c = o.href
c = Mid(c, InStrRev(c, "=") + 1)
List1.AddItem c
End If
End If
Next

String Manipulation
Hi guys, I am wanting to write a function that checks through a string, and when it finds, five spaces in a row, it returns the string before it.

Then it carrys on searching the string when it finds the next 10 spaces in a row. it returns the previous string before.

I know this should be realtively easy but for some reason I can't see how i would do it?

Anyone know???

Thankyou

String Manipulation
Hi all ,

I have a simple question I am working with a string that looks like

" 1/2X014 AB tape". I want to pull out AB from the string and run a query. The lenght of the string changes from time to time but I want to keep track of two alphabets.

Need ur inputs on this ....

String Manipulation
I'm trying to get the portion (1234) of the string below that is between the second and third backslashs. I can do it but it seems to take a lot of manipulation to do so. I'm in the middle of convert some of my old apps to VB.NET and like the split method for string manipulation. Is there anything like it in VB6? Anyone know a quick way of getting the portion I'm looking for?

K:Cortland1234archdetails

Thanks,
Bernie

String Manipulation
I want to cast a String as a Range variable. For some reason my code doesn't work

Dim strAddress as String
Dim rangeAddress as Range

strAddress = "$F$5"
rangeAddress = Range(strAddress)

Any ideas why that doesn't work and how I could go about resolving it?

String Manipulation
Hi,

I have a question about string manipulation in VBA. The task looks like this: I have a range of cells, each containing text about payments, but all in different style, for example "some text 123456 some text 103000000" what I need to do is extract the numeric portions, if present, from the text into different cells, if a number's length is n, then to one cell, if m, then into another.

Right now I have code that checks a string and if it finds a number, then brings it to the cell it is in, right now the problems are that it is limited to 12 characters and the different cell part is missing...

Can anyone help?

Best regards,

Ragnar

String Manipulation
I have a couple of questions:
1. I know there is a function in VB to convert Strings to numeric representation. For instance: "1" to just 1. I just don't remember it. Does any one remebers it?

2. I have a text file with data separated by tabs. How do I find where the column starts (not the first one). I am using
Open importfile For Input As #1 to open it them it has lines like this:
123 records1
124 recor2
and so on. As you can see the start of the second column is not fixed. But the end of the column is.

Thanks!

String Manipulation
Hi guys,

Im reading in a string from a text file and need to remove the speechmarks from it. Is there a constant i can use to select the speechmark?

i would in effect like to do the following in code

replace( sStringTemp, """, "")

which i would like to remove the speechmark. but of course the code thinks im starting and closing strings.

Any ideas?

String Manipulation
Hi,
I have string1 = "00234 45655 12 456 XXX 23456 11 234", and string2 = "XXX". What is the best way to substract string2 from string1 so the result of string1 = "00234 45655 12 456 23456 11 234" ?

Thanks

String Manipulation
How do I strip this string to take the .xml off?


Code:
strTest = "2004_2005_Y3_Maths.xml"

so I end up with: 2004_2005_Y3_Maths

The subject could also be English or Writing?

Code:
strTest = "2004_2005_Y3_English.xml"

Code:
strTest = "2004_2005_Y3_Writing.xml"

String Manipulation
I have a line of text, and it is for a measurement. 12X10

How can i get the first number(12) and the second number(10)?

I tried this.

dim x as integer, n1 as integer, n2 as integer

x=instr(1,text1.text,"x")
n1=left(val(text1.text),x)
n2=left(val(text1.text),x+1)

n1 AND n2 are both the first number.

What am I doing wrong? I tried the Right function, but that didnt get me where I wanted.

Thanks in advance for the help.

String Manipulation
Hey guys how do I separate one line of string when it hits a set character?? Like this


Code:
Dim MyString as String
Private Sub Form_Load()
MyString = "UserName;Password;Admin"
End Sub

How do I get it to take apart the Username when it hits the ; puts it in a variable then goes on until it hits ; again then put the Password in a different variable then put the Admin in a different variable ???

String Manipulation
Hmm im experiencing real problems when it comes to string manipulation.

ok heres the string which comes thru my winsock protocol:


Code:
':irc.server.org NOTICE Nickname :*** If you are having problems connecting due to ping timeouts, please type /quote pong D79E23D8 or /raw pong D79E23D8 now.

thats one line, no vbcrlf's and the "D79E23D8" is random each time, i need to get winsock to respond to it, so


Code:
ws.senddata "pong D79E23D8"

how could i do tha?

String Manipulation
G'day all,

I have a problem with string manipulation and wonder if anyone can assist.

Basicly I have several strings that within each of the strings I want to put a space between 1 block of text ant the next block of text. the prob is that when counting chr's no compensation is made for the varing length of each chr.

This is what it looks like now
wwwww AAAAA
iiiii AAAAA

This is what I would like it to look like (without the extra spacing i have here).

WWWWW AAAAA
IWYN W AAAAA

Any advice appreciated

Garry

String Manipulation Help.
Im new to string manipulation and I was wondering if someone could show me where i can get help or show me how to make a program that
Isolates the first letter of a word and outputs it as a capital.
Counts the number of words in a sentence.
Converts the whole sentence to upper case letters.
Reverses the letters in a word such that CAT would be TAC.

This help would be GREATLY appreciated.

Thanks!

Sincerely,

Myke
http://www.phancy-pants.com
http://www.phancy-pants.com/Icon.gif

String Manipulation
can anyone help with string manipulation?
what i'm trying to do is to create an object out of a string.
ex.

123456789

1
121
12321
1234321
123454321

String Manipulation
I have an app that must read up an ASCII file that is created by a propietary system. That ASCII file contains formatting characters for printers. These are non-standard formatting. I need to be able to search the file for the specific characters, and know the starting position of each character within the string (I've read the file into a string). I can then systematically handle the formatting appropriately.

For example:Line Feed with no indention on the next line: ~{1,0}Line Feed with 9 characters indented on the next line: ~{1,9}3 Line Feeds w/ 9 characters indented: ~{3,9}Form Feed: ~{100,0}
These are just a few examples. There are hundreds or more of these codes. I only need to deal with some of them, but I don't want to keep using the Replace() function to do it. I'd like an array of longs in which each element tells me the starting poing of the ~ for every location in the file that has ~{*,*} where * is some random number of characters.

I've attached a zip file of a sample of one of these ASCII files. Please let me knowif you have any questions! TIA for all your help!

STRING Manipulation
How can I obtain a fixed length string ?
For example I have:
aaa
xxxxx
vv

and I want to print
aaa 3
xxxxx 5
vv 2

I want to obtain from aaa ----> "aaa "

can you show me some code ?
I think I can use format$, but I don't know the exctly format

String Manipulation
Simply Question, is there in VB an "Insert" or a "Delete" function, that works like java's, or c's

String Manipulation
My friend needs help on this:

Write a program that writes a word entered by the user into a code using numbers. A = 1 , B = 2, C = 3 , etc. for example. cat would be changed to 3 1 20. The spaces separate each letter of the word.

To make it simple, do it only for a 3 letter word. For example, cat, dog, gun, etc. We already got how to pick out the letters.

strInput = txtInput.Text
strFirst = UCase(Left(strInput, 1))
'in CAT this returns C
strSecond = UCase(Mid(strInput, 2, 1))
'in CAT this returns A
strThird = UCase(Right(strInput, 1))
'in CAT this returns T

What is the easiest possible way to get this done. Preferably using simple If Then statements or loops?

This is how it would work:
Typing cat in the txtbox (txtInput)
One you hit Generate (cmdGenerate)
it diplays "3 1 20" in the lable (lblAnswer)

Thanks in advanced.

Chris

String Manipulation
Dear all,

need a little help here bout string manipulation...
any1 know how to get a number of character from a string??
ex:
dim aString as string
dim test as string

string = "Example 1 123 this"
i want to assign all the character after the second space into test variable... any1 know how to do it??
thanks in advance for reply....


Angi

String Manipulation
It seems I not the only one trying to extract info from within a string variable.
Hope someone can help.
From my string "C:xxxxxxxxxxxxxxXXXXXX
ecent.mdb"
while it can be any length I need the folder name for the XXXXXX section of the string.

String Manipulation
Simple question, I have a string of any length, how do I trim it down to no more than 100 characters. I'm doing SQL inserts and I think it's dying because one string is overflowing. Is there a concatenate for strings in VB?

String Manipulation
Hi Everyone! I need to know if the following can be done...

- The user pastes the following text into a TextBox (w/ MultiLine Enabled):

X45215 info.domain.web 4324
X43242 info.domain.web 4314
X05235 info.domain.web 4624
X12494 info.domain.web 4304

- By the click of a CommandButton, the above text is converted into:

X45215
X43242
X05235
X12494

Basicaly I would like all the text to be removed after the first 6 characters in each line. If someone could help me with this, that would be great.

String Manipulation
Hi guys,

Iam trying to do string manipulation.
for example if u have a string that has 112x3/4x314 and if it has 3/4 in it then display it otherwise no.

need ur help

String Manipulation
Hi everyone, small problem which is driving me crazy!!
I am reading in a postcode from text file. However the postcodes can be of different lengths e.g. "BT1 1RT" or "BT11 1RT". The problem arises with the first postcode. If I read this in using the following code :-
Trim$(Mid$(ctaxRecCols(postcode_rec.Text),8)) this gives me the string "BT1 1RT"". How do I stop it from reading in the " mark.

Thanks in advance.

String Manipulation (still)
Aright I figured out a BS way to do what I wanted to do, now I'm trying to make it more efficient. I am trying to take all characters that aren't letters, numbers, or commas, out of a text file...in the code below, the text file has already been loaded to a variable called TotalOldFile. I am trying to save my changes to TotalNewFile, but I never get that far. It flips out and gives me an error on the If Left$ line, here is the error.

Run-time Error '13':

Type mismatch

Help Please...



Code:
For x = 1 To LogLength
If Left$(TotalOldFile, x) Like "[a-z]" Or "[0-9]" Then
'Dunno what goes here yet
Else
TotalOldFile = Replace$(TotalNewFile, Left$(TotalOldFile, x), "")
End If
Next x

String Manipulation
How can I delete the first 29 characters of a string?

String Manipulation...i Think
I have written a Flash MX application to run on a Compaq Ipaq. It stores some data to a .sol file (Flash Output), which can be read with notepad as a text file. So far, my VB6 application syncs this file with the Ipaq every time it connects. The file gets dumped to c: emplog.txt every time the Ipaq is connected to the computer. How do I load this file as a variable (string?) and cut out some garbage characters I don't need. I can attach this text file to show you what I'm talking about. At the bottom of the text file is the goal, how I want this log file to look after VB has taken care of it. Thank you anyone who figures this out.

String Manipulation
I have data coming to me in a string that looks like this "1 4 34 67", how can I extract each number so I have:

1
4
34
67

Thanks for your help?

Some String Manipulation
Hi,

I was wondering,

I have a string, for example "I AM GOOD"

what I want is this, to take this string, which conviently is strText and to go though letter by letter. Each letter is to be converted into a number, and then saved. so for example "3 45 2 44 32 21 23" etc. I am able to do single letters, I can find the length of the string, but how can I get it to go from letter to letter, I can compare it's location to the number of characters in the string, to know when to finish, but, not sure how to get from 1 char to another.

thanx

EC

String Manipulation...
Right now, I want to search a string for whatever's between two words. For exampe...

<Title>Whatever</Title>

I want my code to search for <Title>, and store everything from there to </Title> in a string.

I'd appreciate any help, thanks.

String Manipulation
say I have a string = "C:My DocumentsReadMe.txt"

How do i get just the filename "ReadMe.txt" from the pathname

thanks

String Manipulation Help
HI all,

iam trying to program to see if the string starts with 0 then display it in textbox 2 if it starts with E then display it in textbox 2 ,,,


any insight

String Manipulation
I've almost finished designing a server-client chat program. A user can act either as a server or client, and multiple clients can connect and chat with each other and the user. The users are displayed in an MSHFlexGrid, and this works out pretty well. But, whenever a user connects, only the server knows about it. So, I'm trying to create a string which is sent out each time a user connects or disconnects, containing the screen names and ip addresses of the connected users. Here's what I have so far:

[vb]
For i = 0 To .ws.ubound
UserList = UserList & "%" & user(i).uName
UserList = UserList & "^" & user(i).uIP
Next i

% demonstrates a new user, and ^ is merely a seperator between the name and ip address. This works fine, and I end up with a string looking something like this:

%Joe^127.0.0.1%Mike^127.0.0.1

*Remember, I had no idea how to go about doing this, and I have a deadline. If there is a better way to do this, please advise.*

The string gets sent to all of the clients. From here though, I'm not sure how to separate what from what. I have a dynamic array called User() of Classes which i've made containing .uName and .uIP properties.

String Manipulation
Is there a way to convert a quoted string to a VB variable?

I want to read a string value from a file and create a variable with the same spelling as the string and then store a value in the newly created variable.

String Manipulation Help
Hi There,

I have a program that generates a CSV file from out Contacts Database (ACT!v6) and the CSV contains the phone numbers for the contacts but they can be in a number of formats with spaces in.

I am writing another program that searches this CSV file for phone numbers but i need to be able to give it numbers to search for that dont contain spaces.

I am quite happy to strip out the spaces when the CSV is generated but need some help with the code to let me do that.

Could i use the Replace$ Function to replace the Space with nothing? or would i be best using some form of instr function so i could find the position of the space, use left to get number before space then right to get after space then join them together?

Another issue is i will need the code to verifiy it is a number before it starts stripping out the spaces?

Please Help

[string Manipulation]
Code:
Dim iets As String * 7

question,
u can see string iets is 7 chars long
but when i input something in it , that var is not always precisly 7 chars long . so the string automaticly adds null chars or something
how can i change the null chars for spaces
without doing a loop , else i gotta mkek 40 loops or something wich would slow program badly

String Manipulation
Hi again,

I have a string say containg my name 'osk',
i will add a char to the front of the string.

what i want to be able to do id check the first letter of the string to see what it is and then remove it and put the rest of the string in to a variable...

if anyone can point me in the right direction on how to check the first char and then remove it , It would be really appriciated.

TIA.
Osk.

Copyright 2005-08 www.BigResource.com, All rights reserved