Hello dear friends at the VB forums!
Been a while since I last posted here. I'm busy on a new project and I need to convert a string which represents a IP range (like this: 10.0.0.0-10.0.0.254), to two Base64 strings which represents the first and second IP adress in this range definition. Like this: (start IP: CgAAAA== End IP: CgAA/g==)
I've got it to work, but it such an ugly code, and I know it can be done with 2, or at max 4 lines code. But I'm not so handy with the Base64 string conversion jet. So this is where I ask for help from you guys!
Here's what I got (in goes: Apf.Iprange = "10.0.0.0-10.0.0.254")
Thanks for thinking along! So credits for the person who gets this done with the least amount of operatorsCode:Dim StartIp As String = Apf.IPRange.Split("-")(0) Dim EndIp As String = Apf.IPRange.Split("-")(1) Dim StartNumbers() As String = StartIp.Split(".") Dim EndNumbers() As String = EndIp.Split(".") Dim StartBytes As String Dim EndBytes As String Dim sBytes(3) As Byte Dim eBytes(3) As Byte sBytes(0) = Val(StartNumbers(0)) sBytes(1) = Val(StartNumbers(1)) sBytes(2) = Val(StartNumbers(2)) sBytes(3) = Val(StartNumbers(3)) eBytes(0) = Val(EndNumbers(0)) eBytes(1) = Val(EndNumbers(1)) eBytes(2) = Val(EndNumbers(2)) eBytes(3) = Val(EndNumbers(3)) StartBytes = Convert.ToBase64String(sBytes) EndBytes = Convert.ToBase64String(eBytes)![]()




Reply With Quote
