Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Strings - Numbers
#1
Regarding converting string segments to numbers: Strings in numbers

I've looked at it again, and it only really gets complicated when dealing with two-digit numbers. I also tried passing the data to a procedure – the data transfer isn't the problem, only the result.  Rolleyes

The program works as long as you don't go beyond the single-digit range. Maybe this will give someone some ideas.

Code: (Select All)

'ABCDEFGHIJ und 1234567890 tauschen die Plaetze: BCD und 234 -- 26. Dez. 2025
'Erweitert flexible Eingaben - 17. Jan. 2026

Option _Explicit

Dim As String strBuchstaben, strZahlen, strTeilbuchstaben, strTeilzahlen
Dim As String strNeuBuchstaben, strNeuZahlen
Dim As Integer position, bereich

strBuchstaben = "ABCDEFGHIJ"
strZahlen = "1234567890"

Locate 2, 3
Print "Buchstaben - Zahlentausch"
Locate 3, 3
Print "========================="

Locate 5, 3
Print strBuchstaben
Locate 6, 3
Print strZahlen

NeueEingabe:
'Position und Bereich des Austauschs flexibel
Locate 8, 3
Input "Position      : ", position
Locate 9, 3
Input "Bereich(max 3): ", bereich

'Eingabefehler abfangen
If position < 1 Or position > 10 Then

  Cls
  Beep: Print
  Print "Position zwischen 1 bis 10"
  Sleep 2
  GoTo NeueEingabe
End If

'Teilstring von beiden extrahieren. Von Position 2 an,
'3 Positionen. Also: BCD + 234
strTeilbuchstaben = Mid$(strBuchstaben, position, bereich)
Locate 11, 3
Print strTeilbuchstaben

strTeilzahlen = Mid$(strZahlen, position, bereich)
Locate 12, 3
Print strTeilzahlen

'In Buchstaben Zahlen einfuegen. Angabe der Position reicht!
strNeuBuchstaben = Left$(strBuchstaben, position) + strTeilzahlen + Mid$(strBuchstaben, 5)
Locate CsrLin + 2, 3
Print strNeuBuchstaben

'Umgekehrt: Buchstaben in Zahlen
strNeuZahlen = Left$(strZahlen, position) + strTeilbuchstaben + Mid$(strZahlen, 5)
Locate CsrLin + 1, 3
Print strNeuZahlen

End
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Random Numbers PhilOfPerth 16 1,657 10-19-2025, 10:26 PM
Last Post: Pete
  using pseudo-random numbers for repeatable content - kind of a neat trick madscijr 5 992 02-13-2025, 11:12 PM
Last Post: Pete
  random numbers badger 8 1,375 11-08-2024, 02:22 AM
Last Post: DANILIN
  Huge array of variable length strings mdijkens 9 1,787 10-17-2024, 02:01 PM
Last Post: mdijkens
  Identifying colour attributes with negative numbers CharlieJV 1 570 01-28-2023, 05:16 AM
Last Post: CharlieJV

Forum Jump:


Users browsing this thread: